使用 Weex/Vue 进行内联数据绑定?

Inline data binding using Weex / Vue?

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

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