1.页面传值:
源页面:
showScreen(){ let routeData = this.$router.resolve({path:'/company-show',query:{companyId:this.companyId,year:this.year}}); window.open(routeData.href, '_blank'); }
目标页面:
mounted() { this.companyId = this.$route.query.companyId; this.year = this.$route.query.year; },
2.定时器:
mounted() { this.timer=setInterval(this.loadIndustryOrderChart,30000); },
beforeDestroy(){
clearInterval(this.timer);
}
3.引入echarts
const echarts = require('echarts')
4.同时循环多个数据源(多个数据源循环同步):
<li v-for="(item,index) in arr">{{item.name}}{{age[index]}}</li>
5.store:
store用于临时存储全局变量,方便一个地方存储,而另一个地方获取,一般用于页面之间传值等等。
定义一个store
const process = { state: { processId: null }, mutations: { SET_PROCESS_ID: (state, id) => { state.processId = id; } } }; export default process;
然后在写入值的地方:
this.$store.commit("SET_PROCESS_ID", m);
在引用的地方写:
this.$store.state.process.processId
6.axios发出get请求时,遇到数组字段,会生成****[]=,这种形式,出现400解析错误,解决方法:
export function getValue(parameter) { return axios({ url: api.getValue, method: 'get', params: parameter, paramsSerializer: function(params) { return qs.stringify(params, {arrayFormat: 'repeat'}) } }) }
记得引入:import qs from 'qs'