我想學習Vue.JS,並且我所做的組件不是在頁面上呈現。這是我的組件:簡單Vue組件不呈現
import Vue from 'vue'
const card = new Vue({
el: '#card',
data: {
title: 'Dinosaurs',
content: '<strong>Dinosaurs</strong> are a diverse group of animals
from the clade <em>Dinosauria</em> that first appeared at the Triassic
period.'
}
})
這是我的html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Vue Practice</title>
</head>
<body>
<div id="card">
<header>{{ title }}</header>
<div v-html="content"></div>
</div>
<script src="bundle.js"></script>
</body>
</html>
這是的package.json(我知道大多數的依賴性屬於在devDependencies):
{
"name": "vue-practice",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"bundle": "browserify -t babelify -t vueify -e main.js >
bundle.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.0",
"babelify": "^7.3.0",
"browserify": "^14.4.0",
"vue": "^2.4.2",
"vueify": "^9.4.1"
},
"devDependencies": {}
}
當我在瀏覽器中加載index.html,它呈現的只是{{title}},我沒有收到任何錯誤。任何解釋爲什麼發生這種情況將不勝感激!
你使用Vue + Compiler包嗎?發佈你的'package.json'。 – yuriy636
我認爲vueify會完成這項工作,但我會發布整個package.json。 –