1.svg使用
2.vue 修改网页标题
1.在public下的index.html里修改title <title>xx系统</title>
2.document.title = "xx系统"
3.下载图片
window.location="图片网络地址"
4.秒转化为 小时分钟秒
secondsFormat(value) {
var theTime = parseInt(value); // 秒
var theTime1 = 0; // 分
var theTime2 = 0; // 小时
var theTime3 = 0; // 天
if (theTime > 60) {
theTime1 = parseInt(theTime / 60);
theTime = parseInt(theTime % 60);
if (theTime1 > 60) {
theTime2 = parseInt(theTime1 / 60);
theTime1 = parseInt(theTime1 % 60);
}
}
var result = "" + parseInt(theTime);
if (theTime1 > 0) {
result = "" + parseInt(theTime1) + "分" + result;
}
if (theTime2 > 0) {
result = "" + parseInt(theTime2) + "小时" + result;
}
return result;
},
5.秒转化为 天小时分钟秒
formatSecond(value) {
const days = Math.floor(value / 86400);
const hours = Math.floor((value % 86400) / 3600);
const minutes = Math.floor(((value % 86400) % 3600) / 60);
const seconds = Math.floor(((value % 86400) % 3600) % 60);
var forMatDate = "";
if (days) {
forMatDate += days + "天";
}
if (hours) {
forMatDate += hours + "小时";
}
if (minutes) {
forMatDate += minutes + "分钟";
}
forMatDate += seconds;
return forMatDate;
},
7.把时间中的-、/转化
replace(/-/g, "/")
e[0].replace(/\//g, "-");
8.把一位数的时分秒自动填充为两位数
let month='9'
month=("00" + month).substr(-2, 2)
9.javascript 从对象数组中 按字段/属性取最大值或最小值
var array=[
{
value: 100
},
{
value: 20
},
{
value: 50
}];
取最大值:Math.max.apply(Math, array.map((item)=> {return item.value}))
取最小值:Math.min.apply(Math, array.map((item)=> {return item.value}))
10.js在当前时间上加分钟数,得出结果
1.获取当前日期
var date=new Date();
2. 获取当前分钟
var minutes=date.getMinutes();
3. 设置当前时间10分钟前:把当前分钟数+10后的值重新设置为date对象的分钟数
date.setMinutes(minutes+10);
4. 测试
console.log(date.toLocaleString());
11.修改对象key
12.自定义组件上用v-model传递参数
父组件用 v-model
组件接收用
model: {
prop: 'checked',
event: 'input'
},
props: {
checked: {
default: ''
},
}
通知父组件 this.$emit('change', result)
model: {
prop: 'checked',
event: 'input'
},
props: {
checked: {
default: ''
},
}
通知父组件 this.$emit('input', result)
js挂载vue组件并传参
用js挂载.vue组件/动态创建实例,参考链接
挂载的vue怎么传prop 参考链接
父组件
let temp="传递的参数"
let c = document.createElement("div");
c.id = "echart-layout";
let Constructor = Vue.extend(weather);
let toast = new Constructor({ propsData: { viewData: temp } });
toast.$mount();
c.appendChild(toast.$el);
子组件 weather
props: {
viewData: {
type: String,
default: "",
},
},