【发布时间】:2017-02-19 10:43:03
【问题描述】:
我正在尝试访问我传递给单个文件组件的两个属性,如下所示:
<template>
<div>{{ width }} - {{ height }}</div>
</template>
<script>
export default {
data() {
return {
width: this.width,
height: this.height
}
},
props: ['width','height']
}
</script>
这里是 main.js 文件,我使用 browserify/vueify 来创建我包含在我的 html 中的 build.js:
var Vue = require('Vue')
var barchart = require('./components/barchart.vue')
var d3 = require('d3')
var e = new Vue({
el: '#app',
render: function(createElement){
return createElement(barchart)
}
})
HTML 文件:
<div id="app">
<barchart :width="20" :height="20"></barchart>
</div>
我应该得到如下输出:
20 - 20
但我得到了
-
我做错了什么?
【问题讨论】:
标签: vue.js vuejs2 vue-component