国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁技術文章
文章詳情頁

vue組件暴露和.js文件暴露接口操作

瀏覽:84日期:2022-12-10 11:48:37

1、將同一類型的組件放在一個文件夾下

2、在此文件夾下創建一個index.js

vue組件暴露和.js文件暴露接口操作

3、在index.js中導入組件,并把他們暴露出去

1、寫法一

import studentCourse1 from ’./studentCourse.vue’ import studentInfo1 from ’./studentInfo.vue’ export var studentCourse=studentCourse1 export var studentInfo=studentInfo1

2、寫法二

export var studentCourse=()=>import(’./studentCourse.vue’) export var studentInfo=()=>import(’./studentInfo.vue’) //export var studentInfo=()=>{ return import(’./studentInfo.vue’) }

4、最后在.vue文件中使用組件

此處你只需引入index.js所在文件夾就行啦

import {studentCourse,studentInfo} from ’./components/stuCom’ export default{ components:{ ’StudentCourse’:studentCourse, ’StudentInfo’:studentInfo } }

1、將.js放在同一個文件夾下

2、同樣一定要有一個index.js文件

vue組件暴露和.js文件暴露接口操作

3、 index.js文件內容如下

import auth from ’./auth.js’ import error from ’./error-log.js’ export default{ auth, error }

4、在main.js中

import utils from ’./utils’

Vue.use(utils.auth,{params})

補充知識:vue項目中將方法名暴露給APP端調用

只需要將methods中的方法賦值到window對象即可

created() { window.getParams = this.getParams}, methods: { getParams(params) { this.id = params.id // ... },}

也可以賦值給window對象中的某個對象

以上這篇vue組件暴露和.js文件暴露接口操作就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 肥西县| 沙湾县| 莱州市| 高阳县| 邯郸市| 鄂伦春自治旗| 新巴尔虎左旗| 阿拉善右旗| 南漳县| 应用必备| 炉霍县| 安吉县| 贵州省| 淳化县| 南溪县| 沙河市| 隆昌县| 斗六市| 灵璧县| 双柏县| 盱眙县| 沙河市| 准格尔旗| 嘉禾县| 宜丰县| 宁明县| 墨竹工卡县| 肃宁县| 新巴尔虎左旗| 顺昌县| 海宁市| 襄汾县| 新平| 越西县| 无棣县| 镇巴县| 浑源县| 韶山市| 勐海县| 昭通市| 景东|