0
<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 中,我创建了一个具有 title 和 imagePath 属性的可重用组件“profile-header”。看来我只能使用上面提供的代码将数据传递给这两个属性,我需要在其中定义两个变量。

无论如何,我可以通过在那里内联数据将数据传递给我的自定义组件吗?喜欢:

 <profile-header :title="This is the hardcoded title" :imagePath="hard coded path"></profile-header>
4

1 回答 1

1
<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>

在第一种情况下,您根本没有绑定,道具被视为字符串。在第二种情况下,您正在绑定一个硬编码字符串(注意引号)。

于 2017-11-23T05:04:03.533 回答