ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
后台用 kkFileView 做预览文档的功能, 前端增加预览按钮, 按钮封装成了一个组件, 具有预览功能的页面引入组件, 添加到指定位置即可 问题: 每个页面到增加引入预览组件太麻烦, 做成全局的(很多业务都有预览功能) 写好的预览组件是 DocumentPreview .vue 把预览组件放到 DocumentPreview 文件夹下并新建 index.js文件 ``` import preview from './DocumentPreview.vue' const DocumentPreview = { // install 为Vue实例上的一个方法 install: function(Vue) { // 注册全局组件 Vue.component('DocumentPreview', preview) } } // 导出组件 export default DocumentPreview ``` main.js 文件 ``` import DocumentPreview from '@/components/DocumentPreview' // 把文档预览组件添加到全局 Vue.use(DocumentPreview) ```