如何使用 VS 2017 在 asp .net 解决方案中使用 vue-multiselect 标记?
How to use vue-multiselect tagging inside asp .net solution using VS 2017?
我正在尝试使用 vue-multiselect 标记,但我遇到了一些错误,例如:
"vue.js:634 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "名称“选项。”
并且:
"SyntaxError: The requested module 'https://unpkg.com/vue-multiselect@2.1.0' does not provide an export named 'default'"
谁能帮帮我?
我的脚本:
<script type="module">
import Multiselect from 'https://unpkg.com/vue-multiselect@2.1.0'
export default {
components: {
Multiselect
},
data() {
return {
value: [
{ name: 'Javascript', code: 'js' }
],
options: [
{ name: 'Vue.js', code: 'vu' },
{ name: 'Javascript', code: 'js' },
{ name: 'Open Source', code: 'os' }
]
}
},
methods: {
addTag(newTag) {
const tag = {
name: newTag,
code: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000))
}
this.options.push(tag)
this.value.push(tag)
}
}
}
</script>
我的html代码:
<div>
<label class="typo__label">Tagging</label>
<multiselect v-model="value" tag-placeholder="Add this as new tag" placeholder="Search or add a tag" label="name" track-by="code" :options="options" :multiple="true" :taggable="true"></multiselect>
<pre class="language-json"><code>{{ value }}</code></pre>
</div>
我认为使用像 vue-multiselect 这样支持标记的自定义控件正是您所需要的。参见 here。
要呈现 "Exporters" 的列表,您必须将 select 选项设置为动态。根据 Vue.js 文档,您需要执行以下操作:
<select v-model="selected_exporter">
<option v-for="exporter in exporters" v-bind:value="exporter.value">
{{ exporter.description }}
</option>
</select>
<span>Selected: {{ selected_exporter }}</span>
然后如果导出器还不存在,你想输入一个输入,你可以使用v-if
来显示或隐藏输入。
首先包括文件:
<script src="https://unpkg.com/vue-multiselect@2.0.6"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-multiselect@2.0.6/dist/vue-multiselect.min.css">
然后,注册组件:
components: {
Multiselect: window.VueMultiselect.default
},
我在这里找到了解决方案:
我正在尝试使用 vue-multiselect 标记,但我遇到了一些错误,例如:
"vue.js:634 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "名称“选项。”
并且:
"SyntaxError: The requested module 'https://unpkg.com/vue-multiselect@2.1.0' does not provide an export named 'default'"
谁能帮帮我?
我的脚本:
<script type="module">
import Multiselect from 'https://unpkg.com/vue-multiselect@2.1.0'
export default {
components: {
Multiselect
},
data() {
return {
value: [
{ name: 'Javascript', code: 'js' }
],
options: [
{ name: 'Vue.js', code: 'vu' },
{ name: 'Javascript', code: 'js' },
{ name: 'Open Source', code: 'os' }
]
}
},
methods: {
addTag(newTag) {
const tag = {
name: newTag,
code: newTag.substring(0, 2) + Math.floor((Math.random() * 10000000))
}
this.options.push(tag)
this.value.push(tag)
}
}
}
</script>
我的html代码:
<div>
<label class="typo__label">Tagging</label>
<multiselect v-model="value" tag-placeholder="Add this as new tag" placeholder="Search or add a tag" label="name" track-by="code" :options="options" :multiple="true" :taggable="true"></multiselect>
<pre class="language-json"><code>{{ value }}</code></pre>
</div>
我认为使用像 vue-multiselect 这样支持标记的自定义控件正是您所需要的。参见 here。
要呈现 "Exporters" 的列表,您必须将 select 选项设置为动态。根据 Vue.js 文档,您需要执行以下操作:
<select v-model="selected_exporter">
<option v-for="exporter in exporters" v-bind:value="exporter.value">
{{ exporter.description }}
</option>
</select>
<span>Selected: {{ selected_exporter }}</span>
然后如果导出器还不存在,你想输入一个输入,你可以使用v-if
来显示或隐藏输入。
首先包括文件:
<script src="https://unpkg.com/vue-multiselect@2.0.6"></script>
<link rel="stylesheet" href="https://unpkg.com/vue-multiselect@2.0.6/dist/vue-multiselect.min.css">
然后,注册组件:
components: {
Multiselect: window.VueMultiselect.default
},
我在这里找到了解决方案: