假设要在单文件组件中引用其他开源组件:
先将开源组件源文件下载下来,比如github上的git clone下来,找到对应的vue文件,将该文件复制到自己要用到该组件的文件的同一文件夹下。修改自己的文件:
<template>
<div>
<Editor></Editor>
</div>
</template>
<script>
import Editor from './Editor'
export default{
components:{
Editor
}
}
</script>
页面显示出错,没有关系,alt+c取消运行,重新输入npm run,如果失败的话会提示npm install xxx --save ...,输入该命令安装依赖,重新输入npm run,成功调用组件。