Blogger Information
Blog 77
fans 0
comment 2
visits 55718
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
TS和JS混装导出导入MVC里的model模块的写法
南瓜又个梦
Original
662 people have browsed it

实现MVC里的model模块的时候,如果TS和JS混写,导出模块的方法。最好就用ts
JS文件(导出)

  1. const model = {
  2. fetch() {
  3. //return 获取数据
  4. },
  5. save(data) {
  6. //处理设置数据
  7. }
  8. }
  9. //第一种写法
  10. export default model
  11. //第二种写法
  12. export {model}

TS文件(接收)

  1. //第一种写法
  2. const {model}=require('@model.js').default
  3. console.log(model
  4. //第二种写法
  5. const {model}={model}=require('@model.js')
  6. //这是一个析构赋值
  7. console.log(model

区别
在控制台console.log(model)就对比出来了

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post