vue文件中如何写import-该写在什么位置
<p>在.vue文件中,可以在<script>标签中使用import语句来导入其他模块。import语句应该放在<script>标签的顶部,紧接着是<template>标签和<style>标签。例如:</p>
<pre><code><template>
<!-- 模板内容 -->
</template>
<script>
import { foo } from './foo.js'
export default {
// 组件选项
}
</script>
<style>
/* 样式内容 */
</style>
</code></pre>
<p>其中,import语句用于导入名为foo的模块,该模块位于当前目录下的foo.js文件中。需要注意的是,import语句必须放在<script>标签中,不能放在<template>或<style>标签中。</p>
原文地址: http://www.cveoy.top/t/topic/fU0 著作权归作者所有。请勿转载和采集!