Vue base 类封装
-----------------------------------------------------------------------------------------
vue在实际开发中,代码封装demo
这里以多个页面的,查询接口,getlist 为例
分析多个页面 getlist 行为得出
相同点
1 .1 进行网络请求
1.2 将接口结果赋值给变量
1.3 变量 data
不同点
2.1 接口Url
得出 : 子类定义 apiPath ,方法写在父类中
1:父类代码
//基类 base
<template>
<section>
父类的模板层代码
</section>
</template>
<script>
export default {
name: 'base',
components: {
},
data() {
return {
data: {
data:[]
},
name :'base',
};
},
created() {
/**Base-init */
},
methods: {
async getInfo() {
const param = {