在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/HTML/ Vue多層通信,圖片顯示不出來,出現(xiàn)display:none !importan

Vue多層通信,圖片顯示不出來,出現(xiàn)display:none !important

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue多層組件間通信</title>
</head>
<body>
<div id="app">
    <mparent :imgsrc="img" :title="title"></mparent>
</div>

<template id="img_child">
    <img :src="imgsrc" width="200" height="200">
</template>

<template id="title_child">
    <h2>{{title}}</h2>
</template>

<template id="my_parent">
    <div>
        <child1 :imgsrc="imgsrc"></child1>
        <child2 :title="title"></child2>
    </div>
</template>

<script src="js/vue.js"></script>
<script>
    //js相關(guān)代碼

    //子組件的實例
    let childImg = Vue.extend({
        template: '#img_child',
        props: ['imgsrc']
    });

    let childTitle = Vue.extend({
        template: '#title_child',
        props: ['title']
    });

    //注冊父組件
    Vue.component('mparent', {
        props: ['imgsrc', 'title'],
        components: {
            'child1': childImg,
            'child2': childTitle
        },
        template: '#my_parent'
    });

    new Vue({
        el: '#app',
        //Vue 實例的數(shù)據(jù)對象
        data: {
            img: 'img/ad.png',
            title: '真好啊'
        },
    });
</script>

</body>
</html>
回答
編輯回答
尛憇藌

用的你的代碼 沒有問題啊 能出來圖片和文字啊

2017年7月6日 17:51