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

您的位置:首頁技術(shù)文章
文章詳情頁

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

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

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

2、在此文件夾下創(chuàng)建一個index.js

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

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

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文件內(nèi)容如下

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端調(diào)用

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

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

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

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

標簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 巴林左旗| 神木县| 金华市| 乌兰浩特市| 洮南市| 保靖县| 射洪县| 多伦县| 夏邑县| 无锡市| 桂林市| 景洪市| 修水县| 洪雅县| 莱州市| 抚顺县| 长沙县| 治县。| 龙山县| 定兴县| 高台县| 万载县| 和田县| 伊金霍洛旗| 孝感市| 龙山县| 宁化县| 泰安市| 巴塘县| 蓬安县| 广汉市| 赤壁市| 龙海市| 汉中市| 交口县| 兴山县| 岑溪市| 阳西县| 安西县| 灵台县| 西平县|