Vue.js 英雄列表搜索与排序功能实现
<!DOCTYPE html>
<html lang="en"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>英雄列表搜索与排序</title><script src="../js/vue.js"></script>
</head><body><div id="app"><input type="text" placeholder="请输入搜索内容" v-model="keyword"><br><button @click="type=1">升序</button><button @click="type=2">降序</button><button @click="type=3">原序</button><table border="1px"><tr><th>序号</th><th>名字</th><th>能量</th></tr><tr v-for="hero in newArr" :key="hero.id"><td>{{hero.id}}</td><td>{{hero.name}}</td><td>{{hero.power}}</td></tr></table></div><script>new Vue({el: "#app"