vue问题

作者: swhzzz | 来源:发表于2017-06-22 18:07 被阅读0次

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的图片在本地可以显示,但是在生产环境中不显示,很有肯能是用了相对路劲的结果,如:
<img src="../../assets/xxx.png" />
解决办法: <img :src=" './static/xxx.png ' "/>

未完待续

相关文章

  • 【转载】vue3 template模版字符串写法报错: Comp

    【vue3 使用第三方插件问题 bundler to alias “vue“ to “vue/dist/vue.e...

  • vue 图片 显示方案

    相信有些刚入手vue的小白来说 vue 中有许多的问题 我也是刚入手vue 就简单记一记 vue图片展示的问题 v...

  • vue : 无法加载文件 XXX\AppData\Roaming

    一、问题:使用命令行安装完成vue/cli后,使用vue ui/vue create XXX无法创建项目 vue ...

  • vue问题

    vue-router路由跳转有两种模式需要在mode属性填写用的模式,vue有两种模式history模式和hash...

  • vue问题

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

  • vue问题

    一.vue打包成功后访问不到路径 未找到下图路径 方法改为如下打包成功 二.vue报各种规范问题,可以先直接关掉规范检测

  • vue 问题

    watch检测 mint -tab-container 会导致tab-container swiper 死循环

  • vue问题

    1.定时器 使用定时器 最后在beforeDestroy()生命周期内清除定时器: 方案1有两点不好的地方,引用尤...

  • vue 奇怪的Bug

    标题虽然这样起,但是大部分都不是vue的问题,是代码问题 [Vue warn]: $listeners and $...

  • vue-router内嵌iframe页面,回退异常

    问题描述:在vue页面内嵌了iframe,通过$router.back()回退异常 问题分析: 使用vue-rou...

网友评论

      本文标题:vue问题

      本文链接:https://www.haomeiwen.com/subject/bowfcxtx.html