【发布时间】:2018-10-10 16:29:10
【问题描述】:
我正在尝试在带有vue-sweetalert2 的警报中显示以下模板:
<input v-model="name" class="swal2-input">
<select v-model="parent" name="parent" class="form-control">
<option v-for="category in categories" v-bind:value="category.id">
{{category.name}}
</option>
</select>
我在普通模板中没有任何问题,但我不知道如何在SweetAlert2中使用它。
我试过这段代码:
this.$swal({
text: 'edit child',
html:
'<input v-model="name" class="swal2-input">' +
`<select v-model="parent" name="parent" class="form-control">
<option value="">nothing</option>
<option v-for="category in categories" v-bind:value="category.id">
{{category.name}}
</option>
</select>`,
showCancelButton: true,
confirmButtonText: 'edit',
cancelButtonText: 'cancel',
showCloseButton: true,
})
但它什么也没显示。
【问题讨论】:
-
你把这个放在哪里。$swal( ...?
-
在我的组件中,正常的 swal() 没有任何问题
-
你有错误吗?
-
不,但它只是给我看 {{caregory.name}}
-
你的汗水警报内容超出了 Vue 范围
标签: javascript vue.js vuejs2 sweetalert2