njleonzhang / docsify-demo-box-vue

write Vue demo in docsify with instant preview and jsfiddle integration
https://njleonzhang.github.io/docsify-demo-box-vue/.
MIT License
29 stars 36 forks source link

Uncaught SyntaxError: Unexpected token export #9

Open adrianoresende opened 5 years ago

adrianoresende commented 5 years ago

How solve this error?

image

index.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <meta name="description" content="Description">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
</head>
<body>
  <div id="app"></div>
  <script src="//unpkg.com/vue/dist/vue.min.js"></script>
  <script src="//unpkg.com/docsify-demo-box-vue/dist/docsify-demo-box-vue.min.js"></script>
  <script>
    var jsResources = '<scr' + 'ipt src="//unpkg.com/vue/dist/vue.js"></scr' + 'ipt>'
    var cssResources = '@import url("//cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css");'
    var bootCode = 'var globalVariable = "leon"'
    var globalVariable = "leon"

    window.$docsify = {
      name: '',
      repo: '',
      plugins: [
        DemoBoxVue.create(jsResources, cssResources, bootCode)
      ]
    }
  </script>
  <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
</body>
</html>

md:

/*vue*/
<template>
  <div>
    <div class='wrapper'>
      <div>
        <p>author: {{globalVariable}}</p>
        <button :style="style" @click="onClick">test</button>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    data() {
      return {
        globalVariable,
        style: {
          color: 'blue'
        }
      }
    },
    methods: {
      onClick() {
        alert('author: ' + this.globalVariable)
        this.style.color = 'red'
      }
    }
  }
</script>
njleonzhang commented 5 years ago

any difference to the sample?