admin管理员组文章数量:1186689
I'm trying to install Vue Typer in my Nuxt js app but no luck. I keep getting "document not defined". I tried importing it in my nuxt.config.js as a plugin but it doesn't work.
I got it working in my VueCLI 3, seems to work fine with this method.
Appreciate it!
Getting
NuxtServerError render function or template not defined in component: anonymous
////plugins///
import Vue from vue;
if (process.client) {
const VueTyper = require('vue-typer');
Vue.use(VueTyper);
}
///nuxt.config.js///
plugins: [
{src: '~/plugins/vue-typer.js', ssr: false}
],
<template>
<vue-typer text='Hello World! I was registered locally!'></vue-typer>
</template>
<script>
const VueTyper = processs.client ? require('vue-typer'): '';
export default {
components: {
VueTyper
}
}
</script>
I'm trying to install Vue Typer in my Nuxt js app but no luck. I keep getting "document not defined". I tried importing it in my nuxt.config.js as a plugin but it doesn't work.
I got it working in my VueCLI 3, seems to work fine with this method.
Appreciate it!
Getting
NuxtServerError render function or template not defined in component: anonymous
////plugins///
import Vue from vue;
if (process.client) {
const VueTyper = require('vue-typer');
Vue.use(VueTyper);
}
///nuxt.config.js///
plugins: [
{src: '~/plugins/vue-typer.js', ssr: false}
],
<template>
<vue-typer text='Hello World! I was registered locally!'></vue-typer>
</template>
<script>
const VueTyper = processs.client ? require('vue-typer'): '';
export default {
components: {
VueTyper
}
}
</script>
Share
Improve this question
edited Feb 4, 2020 at 11:24
mhrabiee
81510 silver badges23 bronze badges
asked Feb 4, 2019 at 23:29
Kelvin FernandoKelvin Fernando
1211 gold badge1 silver badge4 bronze badges
3
- Please read nuxtjs doc. Modules is for nuxt modules, not random node package. You need plugin with ssr false option. It's all covered in nuxt docs – Aldarund Commented Feb 5, 2019 at 1:34
- 1 Unfortunately it doesnt look like this package can be used in nuxt please see this open issue on there github github.com/cngu/vue-typer/issues/1 this may give you some more information - With saying that though this functionality would be easy to implement yourself, You could look at this stackOverflow question for inspiration stackoverflow.com/questions/34380037/… – Smokey Dawson Commented Feb 5, 2019 at 23:10
- Makes sense. Thank you very much, really appreciate the help! – Kelvin Fernando Commented Feb 6, 2019 at 2:45
1 Answer
Reset to default 33To fix this, create a file called vueTyper.client.js
under plugin folder then type this;
import Vue from 'vue';
import { VueTyper } from 'vue-typer';
Vue.component('vue-typer', VueTyper);
then in your nuxt.config.js
add this to your plugin
plugins: [
{src: '~/plugins/vueTyper.client.js', mode: 'client',}
]
after doing this you can easily use it anywhere in your application without error:
<vue-typer text='Hello World! I was registered locally!'></vue-typer>
本文标签: javascriptHow to Install Vue Packages in nuxtjsStack Overflow
版权声明:本文标题:javascript - How to Install Vue Packages in nuxt.js - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738286026a2072949.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论