我有一个Vue组件调用另一个组件,传递一些道具:
<template>
<div id="weather">
<weather-part class="night" from="0" to="8" data="data"></weather-part>
</div>
</template>
<script>
import weatherPart from "./weatherPart.vue"
export default {
name: 'weather',
components: {
"weather-part": weatherPart
},
data() {
return {
data: {'a': 1, 'b': 2}
}
},
mounted() {
// the place where this.data is actually initialized
}
}
</script>
问题是传递给data
道具的是字符串"data"
(与开发工具的Vue插件一起检查)。
如何传递this.data
的值?(可能是序列化字符串)