首页 > 编程知识 正文

angular计算属性,vue计算属性的使用

时间:2023-05-06 08:31:10 阅读:16852 作者:2192

一、数据要求

(1) fetch

为什么要用?

XMLHttpRequest是一个设计粗糙的API,配置和调用方式非常混乱。

此外,基于事件的异步模型不容易写。

兼容性差,这是W3C的标准,将来实现兼容性的话,一定会发生大火

//getfetch () * ).then ) RES=RES.JSON ) )、then ) RES={console.log(RES ) fetch ) (* ) ) then ) ) headers : { ' content (type ' : ' application/x (www (表单(urlencoded (},fetch((/users ),{method: ) body : JSON.stringify ({ name : ' kerwin ',age:100 } ) }.then () RES=RES.JSON () ) ).then ) RES

注意:

默认情况下,Fetch请求没有cookie,并且必须设置Fetch(URL,{credentials: )

' include'} )

)1) axios

请注意,axios外部封装了数据。

脚本//axios请求,第三方库newvue({El:'#box ),data: ) datalist:(},methods : { BTH (} ) 这是最外层) /箭头函数axios.get('./JSON/test.JSON ' ).then ) ) RES=) TSON,err={console.log(err ); }}}}}/script2,计算属性

复杂的逻辑,模板很难维护

)1)基础实例

)2)缓存vs方法的计算

-计算属性根据它们的依赖关系进行缓存。

-仅当相关依赖关系发生更改时,才会重新评估计算属性

(3)计算属性VSwatch

- v模型

以下是实现模糊搜索的计算属性

divid=' box ' input type=' text ' v-model=' my text ' /! - input type=' text ' @ input=' handle input '//-- ulliv-for=' dataingetmydatalist ' { data } }/Li/ul/divs crist 盒)、data: ) mytext: )、data lisst computed 3360 { get my datalist (} { return this.datalist.filter (item=item.)

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。