1、vue项目中css使用styls编写,当前项目引入相应模块;
输入:
npm install stylus --save-dev
npm install stylus-loader --save-dev
2、styles编写,注意细节
当项目有很多样式公共模块的时候,可以写一个公共引入模块,然后在项目中只引用引入模块的文件,如
1)公共模块如下引用
2)入口main.js引用一次,就可以在项目中随意使用公共模块的方法:
3、组件引用,如:
import heade from “./components/header/header”;
4、安装axios插件,响应http请求
npm install axios --save-dev
然后在main.js引入模块 //import axios from’axios’
将其对象方法继承到Vue对象里 //Vue.prototype.KaTeX parse error: Expected '}', got 'EOF' at end of input: …{ this.http.get(’/api/seller’).then(
(response) => {
console.log(response);
}
)
}
5、解决很多项目控制台的警告
6、组件里运用组件注意小细节
当在组件里运用组件时,或是写组件的时候,切记最外层用一个div包起来,不要出现以下情况
<template>
<div></div>
<div></div>
</template>