Vue2 fails to mount component: template or render function not defined
There are probably the following situations. Simply record…
1. When a page references a component
Let’s take a look at the current directory structure
The directory structure of the current page is viptag/index.vue main page; The components composed of tagroute.js, tagroute.scss and tagroute.vue under component are split because the current component logic and style part are relatively long; At this time, let’s go back to the main page of viptag/index.vue and have a look at import
import tagRule from “./ components/tagRule”; In this case, the specific imported file cannot be recognized, resulting in an error message, which is changed to import tagRule from “./ components/tagRule.vue”; Just
2. When the router/index.js route references the page
Error example
As shown in the figure above, component: The current writing method of require (‘@/views/viptag/index. Vue’) causes an error
The reason is that: require is the module import method of commonjs, and the export default written during component definition is ES6. Therefore, the result of require import is actually an object with default attribute, so components in Vue will report an error when using this, and it happens that components are used for the registration of named view components in Vue, The reasonable usage should be require (‘xxx. Vue ‘). Default or import
Read More:
- VUE: Property or method “deleteFun“ is not defined on the instance but referenced during render. [How to Fix]
- Vue Error compiling template: Component template should contain exactly one root element. If you
- TypeError: res.render is not a function
- React Hook “useState“ is called in function “xxx“ which is neither a React function component or
- Template Render Error Solution (Hexo blog theme, GIT upload)
- Solve the data transfer between vue irrelevant components error: this.$store.commit is not a function
- [Solved] error Component name “index“ should always be multi-word vue/multi-word-component-names
- [Solved] vue.runtime.esm.js?2b0e:619 [Vue warn]: Error in render: “TypeError: Cannot read property ‘length‘
- Vue3 Warning: [Vue warn]: Extraneous non-emits event listeners (changeParentProps) were passed to component
- How to Solve mount error(6): No such device or address
- Template argument deduction/substitution failed: couldn‘t deduce template parameter [How to Solve]
- The tree component in easyUI does not display data or displays undefined solutions
- Vue+TS main.ts error: unused expression, expected an assignment or function call
- Vue error in render: “typeerror: cannot read property ‘length’ of undefined”
- [Solved] Vue Install less Error: this.getOptions is not a function
- [Solved] element-plus Error: Failed to resolve component
- [Solved] thymeleaf.TemplateEngineException processing template “main“: An error happened during template pars
- [Solved] Vue3 Eslint Error: The template root requires exactly one element
- [Solved] VUE Use Filters Error: [Vue warn]: Error in render: “TypeError: Cannot read property ‘toFixed’ of undefined”
- Vue Import Baidu map error: BMap is not defined, eslint BMap reports an error