下面的简单过程不起作用,尽管我不明白为什么……使用: npm vue包
mkdir samat
cd samat
npm init -y
npm install vue --savepackage.json
{
"name": "samat",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"vue": "^2.6.12"
}
}然后创建index.html和index.js
<!DOCTYPE html>
<html>
<head>
<script src="./index.js"></script>
</head>
<body>
<div id="app">
{{ message }}
</div>
</body>
</html>import Vue from 'vue'
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!'
}
})最后,我运行parcel index.html,然后查看localhost:1234,但在浏览器中只能看到以下内容:
{{message}}发布于 2021-01-22 12:45:07
要使用DOM中的模板(即<div id="app>{{ message }}</div>),请导入包含运行时模板编译器的Vue的完整版本:
// import Vue from 'vue'
import Vue from 'vue/dist/vue.esm.browser' // full buildhttps://stackoverflow.com/questions/65647929
复制相似问题