热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

为什么'vue$':'vue/dist/vue.js'需要改成别的别名才会引用正确?

使用vue2.2.6webpack打包后警告

使用vue2.2.6 webpack打包后 警告



1
[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.

尝试用官方文档的解决方案

1
2
3
4
5
6
resolve:{

       

        alias:{

            'vue$':'vue/dist/vue.js'

        }

    }

依旧报错




Uncaught TypeError: Vue is not a constructor

于是把var Vue=require('vue') 修改成var Vue=require('vue').default

又报之前的错误,说明引用的js文件还是不正确

1
2
3
4
5
6
resolve:{

       

        alias:{

            'vuee$':'vue/dist/vue.js'

        }

    }

然后

1
2
3
4
5
6
var Vue=require('vuee');



new Vue({

    el:'#app',

   

})

问题解决,但是我不明白vue的别名为什么不能使用。我在安装vue的时候是用npm install vue --save 的方式安装的,我想应该是node_modules模块引用的优先级高于webpack别名的优先级。

但是我的猜测没有任何依据,希望有人能解答我的疑惑。


   



推荐阅读
author-avatar
破背包
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有