[TOC]
## 1.搜索輸入框搜索功能
>[success] tips:只在輸入框值更改,且為新的值時請求數據
~~~
handleInputChange(value) {
const newVal = value.trim();
if (newVal !== this.lastVal) {
this.lastVal = newVal;
this.$emit("onInputChange", newVal);
}
}
~~~
## 2.使用vuex保存常用數據
>[success] 通過使用actions異步請求數據提交保存至store.state中,方便其他頁面、組件獲取
~~~
actions: {
async saveServiceGroup({ commit }) {
try {
const res = await getServiceGroup();
let group = [];
if (res && res.data) {
commit("saveServiceGroup", res.data);
}
} catch (error) {
console.error(error + "獲取服務分組失敗");
}
},
// ...
}
~~~