vue-cli 使用小技巧

1.关闭烦人的eslint 语法检测,在 config 文件夹下 设置:

// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: false, //设置为false

 

2.引入scss样式文件,在需要引入的组件代码最后加上:

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='scss' scoped>
@import '../assets/scss/friend.scss';  //需要引入的文件
</style>

3.假如你需要在vue中用到其他如jquery的工具或者插件,除了用import方法引入,还可以:

第一步,在入口index.html文件用script标签引入相应的js文件

第二步,把第一步的文件放入和index,html同级目录的static文件夹下

 

4.打包后,输出的文件dist/static/index.html无法用file协议打开,需要在config文件下index.js配置资源公共路径

build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),

// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: './', //改为这个路径

posted @ 2017-12-17 14:32  kzc275  阅读(332)  评论(0编辑  收藏  举报