首页 > 其他 > 详细

vue-cli 使用小技巧

时间:2017-12-17 15:42:48      阅读:193      评论:0      收藏:0      [点我收藏+]

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: ‘./‘, //改为这个路径

vue-cli 使用小技巧

原文:http://www.cnblogs.com/kzc275/p/8052044.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!