关于vue编译版本引入的问题的解决
2019/6/27 7:42:00
本文主要是介绍关于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.
根据错误提示说明,和搜索之后得出结论:是项目引入的vue编译版本不对
解决方案1
build/webpack.base.conf.js 并设置vue的alias别名,如下:
resolve: { alias: { vue: 'vue/dist/vue.esm.js' } }
解决方案2
打开src/main.js修改Vue对象初始化。
new Vue({ el: '#app', router, components: { App }, template: '<App/>' })
改为
new Vue({ el: '#app', router, render: h => h(App) })
原因是,使用 template属性,需要引入带编译器的完整版的vue.esm.js
而如果在.vue文件里面使用
<template> <div></div> </template> <script> export default { name:'name1', data() { return {}; } }; </script>
这种形式,然后使用import引入,则不需要完整版的vue.esm.js,因为使用vue-loader时 *.vue文件会自动预编译成js。
其实vuejs官网中已有明确说明
其他相关文章:
理顺8个版本vue的区别(https://www.zyiz.net/article/147538.htm)
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持找一找教程网。
这篇关于关于vue编译版本引入的问题的解决的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist
- 2024-03-11icons for vue
- 2024-03-07breadcrumbs react js
- 2024-03-06react login page example
- 2024-03-06react router uselocation
- 2024-03-04postgres jsonb_set