2015-12-08 30 views

回答

1

如果您使用Vue的组件,那么你可以做这样的事情:

Vue.Component('my-comp', { 

    template: '#my-template', 

    props: [ 
     'number', 
    ], 
    data: function(){ 
     return{ 
      cabin: 4 
     }; 
    } 
}): 

,然后在你看来,像这样使用:

<my-comp v-show="cabin >= number" number="5"></my-comp> 
<template id="my-template"> 
    <div>Lorem Ipsum</div> 
</template> 
0

一旦你使用了自定义属性(number),我猜你使用了一个组件。

所以,正如他所说@ user3324298,你需要的东西是这样的:

Vue.Component('my-comp', { 
    template: '#my-template', 

    props: ['number'], 

    data: function() { 
    return { 
     cabin: 4 
    } 
    } 
}) 

但模板,应该是这样的:

<template id="my-template"> 
    <div v-show="cabin >= number" number="5"> 
     <div>Lorem Ipsum</div> 
    </div> 
</template> 

<my-comp></my-comp> 

v-show应到组件的范围。

相关问题