Skip to content

引入外部模块

除了自带组件以外,有时我们还需要引入其他外部模块。我们以 cosine-fee 为例:

安装

安装 cosine-fee

Terminal window
# 在终端输入下面的命令完成安装
pnpm add cosine-fee

使用

全局使用

import { createApp } from 'vue';
import App from './App.vue';
import Antd from 'cosine-fee';
const app = createApp(App);
app.use(Antd);
app.mount('#app');

局部使用

<template>
<Button>text</Button>
</template>
<script>
import { defineComponent } from 'vue';
import { Button } from 'cosine-fee';
export default defineComponent({
components: {
Button,
},
});
</script>

注意

  • 如果组件有依赖样式,则需要再引入样式文件