首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Weex / Vue的内联数据绑定?

使用Weex / Vue的内联数据绑定?
EN

Stack Overflow用户
提问于 2017-11-23 04:59:48
回答 1查看 168关注 0票数 0
代码语言:javascript
复制
<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“。看来,我只能使用上面给出的代码将数据传递给这两个属性,其中我需要定义两个变量。

在任何情况下,我都可以通过内联数据将数据传递给自定义组件吗?比如:

代码语言:javascript
复制
 <profile-header :title="This is the hardcoded title" :imagePath="hard coded path"></profile-header>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-23 05:04:03

代码语言:javascript
复制
<profile-header title="This is the hardcoded title" imagePath="hard coded path"></profile-header>

代码语言:javascript
复制
<profile-header :title="'This is the hardcoded title'" :imagePath="'hard coded path'"></profile-header>

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47447855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档