Skip to content

nuxtjs以CDN方式载入waline报语法错误 #1942

Closed Answered by elainecyx
elainecyx asked this question in Q&A
Discussion options

You must be logged in to vote

已解决!
分享给大家解决方案:
nuxt.config.js在head声明以下内容:

head: {
    link: [
      { rel: 'stylesheet', href: 'https://unpkg.com/@waline/client@v2/dist/waline.css' }
    ],
    script: [
      {
        src: 'https://unpkg.com/@waline/client@v2/dist/waline.js',
        type: 'text/javascript',
        pbody: true,
        defer: true
      }
    ]
  }

在xxx.vue页面中
<template><div id="waline" /></template>

在mounted生命周期

const params = new URLSearchParams(location.search.slice(1))
  /* eslint-disable-next-line no-undef */
  return Waline.init({
    el: '#waline',
    path: params.get('path') || '/',
    lang: params.get('lng'),
    serverURL: 'your server url'
  })

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by lizheming
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant