<template>
<div class="demo">
<profile-header :title="profileTitle" :imagePath="profileImagePath"></profile-header>
</div>
</template>
<style scoped>
.demo {
width: 750px;
background-color: #f2f3f4;
}
</style>
<script>
import ProfileHeader from '../components/profile-header.vue'
export default {
components: { ProfileHeader },
data () {
return {
profileTitle: "Lorem Ipsum",
profileImagePath: "http://...."
}
}
}
</script>在Weex中,我创建了一个具有标题和imagePath属性的可重用组件"profile-header“。看来,我只能使用上面给出的代码将数据传递给这两个属性,其中我需要定义两个变量。
在任何情况下,我都可以通过内联数据将数据传递给自定义组件吗?比如:
<profile-header :title="This is the hardcoded title" :imagePath="hard coded path"></profile-header>发布于 2017-11-23 05:04:03
<profile-header title="This is the hardcoded title" imagePath="hard coded path"></profile-header>或
<profile-header :title="'This is the hardcoded title'" :imagePath="'hard coded path'"></profile-header>在第一种情况下,您根本不是绑定,而道具被视为字符串。在第二种情况下,您将绑定一个硬编码字符串(注意引号)。
https://stackoverflow.com/questions/47447855
复制相似问题