我的笔记

//初始化页面
watch: {
    $route() {
      location.reload();
    },
  },


window.open(location.origin + location.pathname + '#/' + item.url, '_blank')

//新开窗口下载
openwin(url) {
var a = document.createElement("a");
a.setAttribute("href", url);
a.setAttribute("target", "_blank");
a.setAttribute("id", "openwin");
document.body.appendChild(a);
a.click();
},

// 导出人员信息
exportInfo(){
let ids = this.selectedChangeData
const loading = this.$loading({
lock: true,
text: '拼命加载中',
spinner: 'el-icon-loading',
customClass: 'el-icon-loadings'
});
exportEmps(ids).then(res => {
let url = res.data.data
this.openwin(url)
}, this.err).finally(() => loading.close())
},


时间组件为空的一些判断
<el-date-picker v-model="cond.leaveDateReal"
value-format="yyyy-MM-dd" format="yyyy-MM-dd"
type="date" @change="changeDateTime"
placeholder="请选择实际离职日期">

</el-date-picker>
changeDateTime(value){
if (value == null) value = ''
},
this.cond.leaveDate == '1970-01-01'||this.cond.leaveDate== 'NaN-NaN-NaN'||this.cond.leaveDate== 'NaNNaNNaN'||!this.cond.leaveDate||this.cond.leaveDate==NaN||this.cond.leaveDate==null


this.$forceUpdate()
新增 清空校验
this.$nextTick(()=>{
// this.$refs[form].clearValidate();
this.$refs.form.resetFields();//等弹窗里的form表单的dom渲染完在执行this.$refs.staffForm.resetFields(),去除验证
});

修改时 清空校验显示数据
this.$nextTick(()=>{
// this.$refs[form].clearValidate();
this.$refs.form.resetFields();//等弹窗里的form表单的dom渲染完在执行this.$refs.staffForm.resetFields(),去除验证
});

this.$nextTick(()=>{
this.$refs.ruleForm.resetFields();
});
this.$nextTick(function(){
this.dialogVisible = true
this.Id = true
this.ruleForm.ID = r.tenantId
this.ruleForm.name = r.tenantName
this.ruleForm.imageUrl = r.logoUrl
let time1 = this.time(r.effectStartTime)
let time2 = null
if(r.effectEndTime){
time2 = this.time(r.effectEndTime)
}else{
time2 = ''
}
this.ruleForm.date1 = time1
this.ruleForm.date2 = time2
})
this.a this.a.b this.a.b='aaa'
this.$set(this.groupsTenan,?'group'+item,?res.data.data.list)

//日期的简单封装  兼容安卓端 苹果端

getDate(data) {
      let seperator1 = "-";
      let datas = new Date(data * 1000);
      let year = datas.getFullYear();
      let month = datas.getMonth() + 1;
      let strDate = datas.getDate();
      let h = datas.getHours() < 10 ? "0" + datas.getHours() : datas.getHours();
      let m =
        datas.getMinutes() < 10 ? "0" + datas.getMinutes() : datas.getMinutes();
      let s =
        datas.getSeconds() < 10 ? "0" + datas.getSeconds() : datas.getSeconds();
      let currentdate =
        year +
        seperator1 +
        month +
        seperator1 +
        strDate +
        " " +
        h +
        ":" +
        m +
        ":" +
        s;
      return currentdate;
    },

示例:2020-12-15 12:05:56

动态循环的图片

<van-cell
              class="todoTaskWrap"
              v-for="(item, index) in list"
              :key="index"
            >
              <div class="item" @click="goto_info(item)">
     <img
                  class="check"
                  @click.stop="itemIscheck(item)"
                  :src="
                    item.ischeck == false
                      ? require('@/assets/images/16.png')
                      : require('@/assets/images/18.png')
                  "
                  alt=""
                />

//css默认

清除浮动
.cf:before, .cf:after {
content:"";
display:table;
}
.cf:after {
clear:both;
}
.cf {
zoom:1;
}

submit () {
let loading = this.$loading()
let div = document.getElementById('form')
let f = div.getElementsByTagName('form')[0]
let inputs = f.getElementsByTagName('input')
let action = f.action + `?mtId=${this.id}`
for (let i of inputs) {
action += `&${i.name}=${i.value}`
}
axios.post(action).then(() => {
this.$message({type: 'success', message: '操作成功'})
this.val = false
}, this.err).finally(() => loading.close())
},


//监听input不是数字 自动清除最后一位
$('#oneInput').on('keyup',function(){
var limitNum = $(this).val().replace(/[^d]/g, "")
limitNum = limitNum.replace(/[`~!@#$%^&*()_-+=<>?:"{}|,./;'\[]·~!@#¥%……&*()——-+={}|《》?:“”【】、;‘’,。、,.]/im, "");
if(limitNum ==0){
limitNum = ''
}
$('#oneInput').val(limitNum)
})

//滚动
var scrollHeights = obj.parents('.readItem')[0].offsetTop
obj.parents('.infor_cont_kecheng').animate({ scrollTop: scrollHeights }, 200)

//
var height = document.getElementsByClassName('infor_cont_wrap')[1].scrollTop
console.log(height)
var timer = setInterval(function(){
height--
if(height == 0){
alert(11)
clearInterval(timer)
return false
}
document.getElementsByClassName('infor_cont_wrap') [1].scrollTo(0,height)

},10)

var height = document.getElementsByClassName('infor_cont_wrap')[1].scrollTop
console.log(height)
var timer = setInterval(function(){
height = height - 2
if(height < 2){
alert(11)
clearInterval(timer)
return false
}
document.getElementsByClassName('infor_cont_wrap') [1].scrollTo(0,height)

},1)

//大数据运用此方法去创建虚拟节点 只需要添加一次
function addSchoolNameListener() {
$('#registerPanel').on('input propertychange', '.schoolName', function() {
var name = $(this).val()
var schoolData = []
for (var i = 0, len = curSchoolList.length; i < len; i++) {
if (curSchoolList[i].itemValue.includes(name)) {
schoolData.push(curSchoolList[i])
}
}
var ul = document.getElementById('schoolList');
$('#schoolList').html('')
// 创建虚拟节点
var fragment = document.createDocumentFragment();
for (var i = 0, len = schoolData.length; i < len; i++) {
var li = document.createElement("option");
li.innerText = schoolData[i].itemValue;
fragment.appendChild(li);
}
ul.appendChild(fragment);
});

<el-menu class="left-menu" :default-active="$route.name" :unique-opened="true" :collapse="isCollapse">
      <template v-for="(m, x) in menuOpts.data" >
        <el-submenu v-if="m.children.length && m.show" :index="m.value" class="level1-menu" :key="x">
          <template slot="title">
            <e-icon :name="m.icon"></e-icon>
            <span>{{m.label}}</span>
          </template>
          <el-menu-item-group v-if="m.children.length && m.show == true">
            <template v-for="c in m.children">
              <el-submenu v-if="c.children && c.show == true" :index="c.value">
                <template slot="title">{{c.label}}</template>
                <el-menu-item class="level2-menu submenu" v-for="(child, s) in c.children" :key="s" @click.native="stateGo(child.value,1)" :index="child.value">{{child.label}}</el-menu-item>
              </el-submenu>
              <el-menu-item v-if="!c.children && c.show == true" :index="c.value" @click.native="stateGo(c.value,2)" class="level2-menu submenu">
              <template slot="title">
                <span>{{c.label}}</span>
              </template>
            </el-menu-item>
            </template>
          </el-menu-item-group>      
        </el-submenu>
        <el-menu-item v-if="!m.children.length && m.show == true"
          :index="m.value" @click.native="stateGo(m.value,0)" class="level1-menu submenu" :key="x">
          <e-icon :name="m.icon"></e-icon>
          <span slot="title">{{m.label}}</span>
        </el-menu-item>
      </template>
    </el-menu>
原文地址:https://www.cnblogs.com/dreammiao/p/14138620.html