ruby web 实战(9)-vue 3基础(2)

发布时间 2023-07-31 17:37:18作者: 水宝石

定位到导入的 vue

使用导入映射表 (Import Maps) 来告诉浏览器如何定位到导入的 vue:

<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <title>world</title>
</head>
<body>


<script type="importmap">
  {
    "imports": {
      "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
    }
  }
</script>

<div id="app">{{ message }}</div>

<script type="module">
  import { createApp, ref } from 'vue'

  createApp({
    setup() {
      const message = ref('Hello Vue!')
      return {
        message
      }
    }
  }).mount('#app')
</script>

</body>
</html>