【发布时间】:2018-08-24 11:53:35
【问题描述】:
我正在尝试学习 Vue 并遇到了这个问题。
Vue.component('alert', {
props: ['type', 'bold', 'msg'], template: '<div class="alert alert-{{ type }}" role="alert"><b>{{ bold }}</b> {{ msg }}</div>'
});
var componentProps=new Vue( {
el: '#app',
}
);
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div id="app" class="container">
<alert type="info" bold="Greetings." msg="This is some information."></alert>
<alert type="warning" bold="Slow down." msg="You might crash."></alert>
<alert type="danger" bold="Oh no!" msg="The program just crashed!"></alert>
<alert type="success" bold="Rock Out" msg="with your Props out!"></alert>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
这是在检查器的输出中。你可以看到 props[type] 在那里没有改变。
<div role="alert" class="alert alert-{{ type }}'"><b>Slow down.</b> You might crash.</div>
codepen 链接 => https://codepen.io/dakata911/pen/XEKbyq?editors=1010
【问题讨论】:
标签: vue.js vuejs2 vue-component