• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

场景

有些时候,我们需要将一个页面拆分成各个模块。

这些模块包含增加,删除,修改,等

并且这些模块会处理非常复杂的业务逻辑问题

所以,我们最好是将他们分开。

如何将分离新增模块拆离出去

主页面

模板

差异

El-button @ click=' addhandler '新增/el-button

保险商实验所

Li v-for=' item in list arr ' : key=' item。id为“{ item。name } }/Li

/ul

/div

/模板

脚本语言设置

从“vue”导入{ ref}

//导入新增模块的业务逻辑,注意不能够写成add.ts

从'导入添加挂钩./add '

//定义接口

接口列表类型{

名字?字符串,

年龄?号码,

id :字符串,

//可以有任意多个字段-任意类型

[propN:string]:any,

}

let listArr=reflistType[]([

{name: '张三,年龄:21,id:'001'},

{name: '李四,年龄:20,id:'002'},

{name: '周六,年龄:28,id:'004 ',aa:'xx'},

])

//使用新增模块

let { addHanlder }=添加钩子(list arr。值);

/脚本

add.ts文件

//新增功能的逻辑

//注意这里需要说明利斯塔尔的参数类型哈{姓名?串;年龄?号;id: string }[]

函数addHooks(listArr: { name?串;年龄?号;id: string }[]) {

函数addhandler(){

listArr.push(

{name: '王五,年龄:24,id:'005'}

)

}

返回{

阿德汉德尔

}

}

导出默认附加挂钩

rruofccrwik5266.png

Link to comment
Share on other sites