Closed adsellor closed 6 years ago
I have the exact same problem.
import particles from './vue-particles.vue'
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (webpack:/external "vue-particles":1:0)
at __webpack_require__ (webpack:/webpack/bootstrap 7f7a613301cb2ec9756c:25:0)
at Object.59 (0.server-bundle.js:121:72)
at __webpack_require__ (webpack:/webpack/bootstrap 7f7a613301cb2ec9756c:25:0)
at Object.72 (components/particle.vue:7:0)
at __webpack_require__ (webpack:/webpack/bootstrap 7f7a613301cb2ec9756c:25:0)
The same here.
@adsellor @sobolevn @paerallax
I will check this out ASAP
Hello friends,
The best way I have found to implement vue-particles with Nuxt JS is to disable server side rendering after implementing it as a plugin.
As mentioned in the nuxt js docs for client-side rendering only.
Install vue-particles
Create a link to use vue-particles as plugin
plugins/vue-particles.js
import Vue from 'vue'
import VueParticles from 'vue-particles'
Vue.use(VueParticles)
in nuxt.config.js
module.exports = {
plugins: [
{ src: '~/plugins/vue-particles', ssr: false }
]
<vue-particles color="#FFFFFF" />
Hopefully this is a sound solution because this is the first search result on Google. Use the vue-particles tag in your layouts file and the particles will not be re-rendered unless the layout changes.
@justinhodev its working in layout files, but not in pages, i need tht on my pages and when i added the <vue-particles/>
tag inside my page i got this error Cannot read property 'getElementsByClassName' of null
. what should i do?
thx
@fidellr change the config options ssr: false
:
plugins: [
{ src: '@/plugins/vue-particles', ssr: false }
]
@liran319 your solution doesn't work. It still throws the same error.
@liran319 @justinhodev - also not working for me, am i missing something, was this broken in a more recent version? I can get this working in pages but not layouts, and it only renders if i load into the page from a router link
I can't get it to work either, not sure what I'm missing.
Cannot read property 'getElementsByClassName' of null
I can also see it load if I go to another link and then return, but on initial page load or refresh it is not there, and that error persists in the console.
I'm using this in a page since it was not working in the layout. The page is fine, but it needs to load and I'm not sure how to resolve that error.
<no-ssr>
<vue-particles color="#ffffff"/>
</no-ssr>
@jordanboston @ezamelczyk wrapping it around <no-ssr>
tag fixed it.
@Brianvdb this is also what worked for me in the end
@Brianvdb Yes with
<vue-particles color='#ffffff'>
<p>Lorem ipsum</p>
</vue-particles>
does not show the <p>
text at all, just shows the particles working normally in the area.
Is it working for you? Is there something more that needs to be done so that more html can be inserted in the particles area? I am trying to achieve something simple like in demo page of vue-particles.
I have been trying to use vue-particles with nuxt.js, but it doesn't work. Found this issue https://github.com/nuxt/nuxt.js/issues/673. Have the same exact errors but cannot fix no matter what.
It seems like @Atinux's PR https://github.com/creotip/vue-particles/commit/a4c290346f029ed61dc4bafa0eb12d60ad09c21a should have fixed the problem, but the error message is still there