您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

利用angular、react和vue实现相同的面试题组件

2025/10/22 13:05:31发布18次查看
react 和angular,vue 这三个框架最近都比较火,本文主要给大家介绍的是关于angular、react和vue实现相同的面试题组件的相关内容,分享出来供大家参考学习,下面话不多说了,来一起看看详细的介绍吧。
面试题要求如下所示
1、angular:
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>document</title> <script src="angular-1.4.6.js"></script> <style> .del{ text-decoration: line-through; color: red; } .in1{ margin-left: 40px; } </style> </head> <body ng-app="app" ng-controller="my-ctrl"> <input type="text" ng-model="val"> <button ng-click="add()">添加</button> <ul> <li ng-repeat="(key,item) in items" ng-show="flag||!items[key].labs" ng-class={true:'del',false:'unselected'}[items[key].labs]><input type="checkbox" ng-click="labe()" ng-model="lab">{{item.text}}<input type="button" value="删除" ng-click="delate()" class="in1"></li> </ul> <button type="button" ng-click="showall()">已完成开关显示</button> <button type="button" ng-click="delateall()">清除已完成</button> </body> <script type="text/javascript"> var myapp = angular.module(app,[]); myapp.controller(my-ctrl,function($scope){ $scope.items = []; $scope.flag = 1; $scope.add=function(){ $scope.items.unshift({text:$scope.val,labs:0});  } $scope.delate=function(){  $scope.items.splice(this.$index,1); } $scope.labe=function(){  $scope.items[this.$index].labs=this.lab; } $scope.showall=function(){ if($scope.flag == 0){ $scope.flag = 1; } else{ $scope.flag = 0; } } //倒序删除数组元素 //这里必须使用倒叙删除数组因为angular数据双向绑定,正序的话会导致数据随时更新影响for循环 $scope.delateall=function(){  for(var i=$scope.items.length-1;i>=0;i--){ if($scope.items[i].labs==true){ $scope.items.splice(i,1); } } } //delateall除了这种方式书写还有另外一种正序删除的方式 //$scope.delateall=function(){ //$scope.delall=[]; //for(var i=0;i<$scope.items.length;i++){ //if($scope.items[i].labs == true){ //console.log(i); //$scope.delall.push(i); //}  //} //console.dir($scope.delall); //for(var j=0;j-1;i--){ if(this.alll[i].check1==true){ this.alll.splice(i,1); } } // for(let i = 0;i 以上就是利用angular、react和vue实现相同的面试题组件的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product