在没有 ES6 编译器的情况下将 vue-konva 与 cdn 一起使用

use vue-konva with a cdn and without a ES6 compiler

可以在没有 ES6 编译器的情况下将 vue-konva 与 cdn 一起使用,我尝试了本页提供的下一个代码 https://konvajs.github.io/docs/vue/

<html>
  <head>
    <meta charset='utf-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
    <meta http-equiv='x-ua-compatible' content='ie=edge'>
  </head>
  <body>
    <div id='app'>
      <v-stage ref="stage" :config="configKonva">
        <v-layer ref="layer">
          <v-circle :config="configCircle"></v-circle>
        </v-layer>
      </v-stage>
    </div>
    <!--1. Link Vue Javascript & Konva-->
    <script src='https://unpkg.com/vue/dist/vue.js'></script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/konva/1.7.6/konva.js'></script>
    <!--2. Link VueKonva Javascript (Plugin automatically installed)-->
    <script src='./lib/vue-konva.min.js'></script>
    <script>
      // 3. Create the Vue instance
      new Vue({
        el: '#app',
        data: {
          configKonva: {
            width: 200,
            height: 200
          },
          configCircle: {
            x: 100,
            y: 100,
            radius: 70,
            fill: 'red',
            stroke: 'black',
            strokeWidth: 4
          }
        }
      })
    </script>
  </body>
</html>

但是 ./lib/vue-konva.min.js 不存在,当我删除该行时

vue.js:616 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

vue.js:616 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.

作为注释,src='./lib/vue-konva.min.js'是相对路径。您需要在本地或 CDN 上安装此文件 link

在这里你可以找到来自jsDelivr

的旧版本

更改您的代码

<script src='https://cdn.jsdelivr.net/npm/vue-konva@1.0.7/lib/vue-konva.min.js'>
</script>

Demo on codepen