vue问题

1.在vue和webpack一同使用时,当在index.js的头部像这样import Vue from 'vue'加载vue时,会报错

[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.

解决方法是在webpack配置文件中加入

resolve: {
        alias: {
            vue: 'vue/dist/vue.js'
        }
    }

2.单文件组件引入sass的方法
首先安装npm i sass sass-loader node-sass --save-dev(这里有可能node-sass安装失败,切换到淘宝镜像源下载即可)
方法一.在单文件组件的style里加上lang="sass" src='path/to/scss'即可,注意此方法加了src后再style里编写的scss无效
方法二.在style里加上lang="scss" rel="stylesheet/sass"然后在style里引入文件@import "path/to/scss"即可,此方法在style中编写的scss任然有效

3.vue中img引入图片报错问题
如果vue中img的图片在本地可以显示,但是在生产环境中不显示,很有肯能是用了相对路劲的结果,如:

解决办法:

未完待续

你可能感兴趣的:(vue问题)