网站首页 > 资源文章 正文
(function ($) {
'use strict';
var base_url = localStorage.getItem("apihost");
var app;
var vm = {
rescueId : '',
fire_width: 0, //长边长
fire_height: 0, //短边长
rescue : {"name":"消防信息"},
rescueItems : [],
auth : 'NG',
extendContent: {},
}
window.onload = function () {
app = new Vue({
el: '#app',
data: vm,
//当其依赖的属性的值发生变化时,计算属性会重新计算,反之,则使用缓存中的属性值。
//不支持异
//html示例:<td>{{zyTotal(item)}}</td>
computed : {
zyTotal : function(){
return function(item) {
let result = 0;
if (item.extendContent.zyds) {
result += item.extendContent.zyds;
}
if (item.extendContent.zybk) {
result += item.extendContent.zybk;
}
if (item.extendContent.zyxmt) {
result += item.extendContent.zyxmt;
}
return result;
}
}
},
beforeCreate(){
console.log('beforecreate:',document.getElementById('first'))//null
console.log('data:',this.text);//undefined
this.sayHello();//error:not a function
},
created(){
console.log('create:',document.getElementById('first'))//null
console.log('data:',this.text);//this.text
this.sayHello();//this.sayHello()
},
beforeMount(){
console.log('beforeMount:',document.getElementById('first'))//null
console.log('data:',this.text);//this.text
this.sayHello();//this.sayHello()
},
mounted(){
console.log('mounted:',document.getElementById('first'))//<p></p>
console.log('data:',this.text);//this.text
this.sayHello();//this.sayHello()
$('#searchInput').keydown(function (event) {
if (event.keyCode == 13) {
_this.searchLists();
}
});
},
//监听属性:一定是data中存在的属性,当监听的属性发送变化是触发
//当需要在数据变化时执行异步或开销较大的操作时,这个方式是最有用的。这是和computed最大的区别
//支持异步
watch: {
"rescueId": function (newval,oldval) {
//todo
},
"fire_height": function (newval) {
//todo;
}
},
//过滤需要匹配的数据
//html示例1 <td v-html="$options.filters.compareNum(item.extendContentJSON.dd.data[0])"></td>
//html示例2 <td>{{item.extendContentJSON.dd.data[0] | preLabel2Num}}</td>
filters : {
preLabel2Num : function(value){
if(value && value.preLabel){
return value.preLabel;
}else {
return 0;
}
},
compareNum : function(value){
if(!value || !value.currLabel || !value.preLabel) {
return "0%";
}else {
let currLabel = value.currLabel;
let preLabel = value.preLabel;
if(currLabel > preLabel) {
//上升
let num =parseInt((currLabel - preLabel) * 100 /preLabel );
return "<p style='color:red;font-size: 10px;'>↑" + num + "%" + "</P>"
}else if (currLabel < preLabel){
//下降
let num =parseInt((preLabel - currLabel) * 100 /preLabel );
return "<p style='color:green;font-size: 10px;'>↓" + num + "%" + "</P>"
} else {
return "0%";
}
}
}
},
methods :{
bindEvent : function(){
this.$nextTick(() => {
$(" input[ type='number' ] ").bind('focus',function(){
$('#publishButton').css('position','static');
}).bind('blur',function(){
$('#publishButton').css({'position':'fixed','bottom':'0'});
});
$(" textarea").bind('focus',function(){
$('#publishButton').css('position','static');
$(this).css({'height':'auto','overflow-y':'hidden'}).height(this.scrollHeight);
}).bind('blur',function(){
$('#publishButton').css({'position':'fixed','bottom':'0'});
}).bind('input', function () {
$(this).css({'height':'auto','overflow-y':'hidden'}).height(this.scrollHeight);
});
})
},
save: function (num) {
}
}
});
}
})(Zepto);
猜你喜欢
- 2024-09-26 如何避免重复提交?分布式服务的幂等性设计
- 2024-09-26 聊聊如何实现一个带幂等模板的Kafka消费者
- 2024-09-26 Docker 安装 Kibana(DOCKER 安装UNTUNTU 图形界面 装不上)
- 2024-09-26 「优雅代码」03-optional杜绝空指针异常
- 2024-09-26 Mybatis plus通用字段自动填充的最佳实践总结
- 2024-09-26 不吹牛逼,撸个注解有什么难的(切记不吹牛)
- 2024-09-26 ElasticSearch入门一:入门安装和索引基本操作
- 2024-09-26 如何优雅地记录操作日志?(如何优雅地记录操作日志)
- 2024-09-26 使用Java8改造出来的模板方法真的是yyds
- 2024-09-26 java利用枚举与数据库交互(java利用枚举与数据库交互方式)
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- 电脑显示器花屏 (79)
- 403 forbidden (65)
- linux怎么查看系统版本 (54)
- 补码运算 (63)
- 缓存服务器 (61)
- 定时重启 (59)
- plsql developer (73)
- 对话框打开时命令无法执行 (61)
- excel数据透视表 (72)
- oracle认证 (56)
- 网页不能复制 (84)
- photoshop外挂滤镜 (58)
- 网页无法复制粘贴 (55)
- vmware workstation 7 1 3 (78)
- jdk 64位下载 (65)
- phpstudy 2013 (66)
- 卡通形象生成 (55)
- psd模板免费下载 (67)
- shift (58)
- localhost打不开 (58)
- 检测代理服务器设置 (55)
- frequency (66)
- indesign教程 (55)
- 运行命令大全 (61)
- ping exe (64)
本文暂时没有评论,来添加一个吧(●'◡'●)