Project scenario:
Today, in the process of reviewing the basis of Vue, I tried to introduce and use Vue with traditional HTML and native memory, and then found that I really pulled it. The memory is not only vague, but also confused. Vue2 mixed with vue3 is there! Next, let’s see how to report the error.
Problem Description:
The HTML structure is as follows:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
</head>
<body>
<div id="app"></div>
</body>
<script>
const app = Vue.createApp({
data() {
return {
message: '666'
}
},
template: "<h2>{{message}}</h2>"
})
app.mount("#app")
</script>
</html>
Good guy, 666 didn’t render. Just click and report me the error
Uncaught TypeError: Vue.createApp is not a function。
I’m still wondering. I think it’s ok if createapp creates a Vue application and mount it to the node?Why, vue.createapp is not available yet
Cause analysis:
Later, I read the document and found that I had mixed up vue.createapp and mount, which are the writing methods of vue3, but I introduced vue2
it is clearly written on the official website. Vue2 uses new and is an EL mount node
vue2 is written as follows:
var app = new Vue({
el: '#app',
data: {
message: '666',
},
template: '<h2>{{message}}</h2>',
});
The following is the way vue3 is written
const app = Vue.createApp({
data() {
return {
message: '666'
}
},
template: "<h2>{{message}}</h2>"
})
app.mount("#app")
Read More:
- Method to solve uncaught typeerror: cannot set property ‘onclick’ of null error
- [Solved] Vue uses webpack to package error: Createapp is not a function
- Asynchronous loading method of Baidu map
- [Solved] JS Error: Uncaught TypeError: Cannot set properties of null (setting ‘innerHTML‘)
- The solution to the failure of HTML introducing external JS
- [Solved] Binding onclick event in JS: for loop: error uncaught typeerror: cannot set properties of undefined (setting ‘classname’)
- [Solved] Vue3 Import element UI error: Uncaught TypeError: Cannot read properties of underfined…
- H5 page left and right stretch content area
- OTS parsing error: invalid version tag [How to Solve]
- [Solved] Vue3.2 component computed Error: Write operation failed: computed value is readonly
- JS bug Log Uncaught TypeError: Cannot read property ‘previoustSibling‘ of null
- [Solved] Vue3 Install vuetify Error: Error: You cannot call “get” on a collection with no paths.
- Vue cannot read property ‘xxx’ of undefined solutions
- [Solved] VUE D:\project\vueProject\vue-02\src\components\hello.vue 5:5 error Parsing error: x-invalid-end-tag
- vue Error: Uncaught SyntaxError: Invalid shorthand property initializer
- npm ERR code ELIFECYCLE [How to Solve]
- [Solved] el-tree setCheckedNodes Error: undefined (reading setCheckedNodes)
- [Solved] Deploy the front-end package online. Net:: err_SSL_PROTOCOL_ERROR
- [Solved] NPM Error: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed
- [Solution] VUE.js Load a local image with parameters in the script