我尝试在我的Nuxt项目中使用这个库:开始-开始
我试过如何在文档中编写,但是在所有的变体中都会出现一个错误--例如:未知的自定义元素:--您正确地注册了组件吗?
对于递归组件,请确保提供"name“选项。我试过的是:
<template>
<div class="div-wrapper">
<h1>grge</h1>
<div id="typeahead"><typeahead :data="USstate" placeholder="USA states">
</typeahead></div>
</div>
</template>
<style lang="less">
.div-wrapper {
background: #f4f4f4;
padding: 95px 15px 50px 15px;
}
</style>
<script>
import Vue from 'vue';
export default {
data() {
return {
USstate: ['Alabama', 'Alaska', 'Arizona'],
asyncTemplate: '{{ item.formatted_address }}',
githubTemplate: '<img width="18px" height="18px" :src="item.avatar_url"> <span>{{item.login}}</span>'
}
},
mounted(){
var typeahead = require('vue-strap/src/Typeahead');
Vue.component('typeahead',typeahead);
new Vue({
el: 'typeahead'
})
},
methods: {
googleCallback(items, targetVM) {
const that = targetVM;
that.reset()
that.value = items.formatted_address
},
githubCallback(items) {
window.open(items.html_url, '_blank')
}
}
}
</script>获取错误:窗口未定义。比我试试看:
mounted(){
var typeahead = require('vue-strap/src/Typeahead');
Vue.component('typeahead',typeahead);
new Vue({
el: 'typeahead'
})
}呈现但有许多错误:

并尝试编写插件,如何在ru.nuxtjs.org/示例/plugins中进行描述,但没有成功。请帮我正确地插入这个图书馆。
发布于 2017-03-14 09:42:26
我在vue-touch上也遇到了同样的问题,我按照Nuxtjs.Org的建议将它作为插件添加到插件中来解决这个问题。
工作流程
文档
有关更多信息,您可以在nuxtjs.org 文档中查看。
https://stackoverflow.com/questions/41761761
复制相似问题