Встроенная привязка данных с помощью 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 я создал повторно используемый компонент «profile-header» со свойствами title и imagePath. Похоже, что я могу передать данные только этим двум атрибутам, используя код, представленный выше, где мне нужно определить две переменные.

В любом случае, я могу передать данные в свой пользовательский компонент, вставив данные прямо туда? Нравиться:

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

person mkto    schedule 23.11.2017    source источник


Ответы (1)


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

or

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

В первом случае вы просто не привязываетесь, а свойства обрабатываются как строки. Во втором случае вы привязываете жестко закодированную строку (обратите внимание на кавычки).

person Bert    schedule 23.11.2017