Skip to content

Instantly share code, notes, and snippets.

@wallleap
Created September 6, 2023 02:13
Show Gist options
  • Select an option

  • Save wallleap/cfb6595bc525e0dd3aadfe0235ebc35f to your computer and use it in GitHub Desktop.

Select an option

Save wallleap/cfb6595bc525e0dd3aadfe0235ebc35f to your computer and use it in GitHub Desktop.
启用 Import maps
我们可以使用导入映射表 (Import Maps) 来告诉浏览器如何定位到导入的 vue:
```html
<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 } from 'vue'
createApp({
data() {
return {
message: 'Hello Vue!'
}
}
}).mount('#app')
</script>
```
你也可以在映射表中添加其他的依赖——但请务必确保你使用的是该库的 ES 模块版本。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment