1.当盖视点设置填充属性时边界半径不生效
2.获取对象属性的个数Object.getOwnPropertyNames(testObj)。长度
3.Vue.js当绑定事件和类名一样时页面一片空白也不报错!
4.vue只能有一个根元素
5.Vue不允许在已经创建的实例上动态添加新的根级响应式属性。
6.Vue不能检测到对象属性的添加或删除或修改,最好的方式就是在初始化实例前声明根级响应式属性,哪怕只是一个空值。
7.使用VUE全局方法设置对象属性可以使VUE检测到属性的添加和删除但依旧不能检测到修改
8.数组弹出()删除最后一个推()添加最后一个移位()删除第一个不印字()添加第一个
9.小程序在页面配置css overflow-hidden页面就不滚动了
10.vue v-if v-else v-for别挂在一个标签使用!会爆炸
11.Vue在富文本中绑定事件在渲染出来事件不生效要这样搞
mounted:function(){
this.$nextTick(() => {
// Code that will run only after the
// entire view has been rendered
$(this.$el).on('click', "img", (e) => {
console.log(e.target.src)
})
})
},
//$nextTick dom更新 nextTick数据更新
//this.$refs.article 绑定任意对象
12. vue中指令的用法
<input v-local-test />
directives:{
'local-test':function(el,binding,vnode){
/** el可以获取当前dom节点,并且进行编译,也可以操作事件 **/
/** binding指的是一个对象,一般不用 **/
/** vnode 是 Vue 编译生成的虚拟节点 **/
el.style.border="1px solid red"; //操作style所有样式
console.log(el.value); //获取v-model的值
console.log(el.dataset.name) //data-name绑定的值,需要el.dataset来获取
console.log(vnode.context.$route); //获取当前路由信息
}
},
13.onpopstate检测历史变化pushState的的的的的的的设置历史记录replaceState更改历史记录
让对方手机不能返回 超暴力!
window.onpopstate = function(event) {
history.pushState({page: 3}, "title 3", "?page=3");
alert("location: " + document.location + ", state: " + JSON.stringify(event.state));
};
//绑定事件处理函数.
history.pushState({page: 1}, "title 1", "?page=1"); //添加并激活一个历史记录条目 http://example.com/example.html?page=1,条目索引为1
history.pushState({page: 2}, "title 2", "?page=2"); //添加并激活一个历史记录条目 http://example.com/example.html?page=2,条目索引为2
//history.replaceState({page: 2}, "title 3", "?page=3"); //修改当前激活的历史记录条目 http://ex..?page=2 变为 http://ex..?page=3,条目索引为3
//console.log(history)
//history.back()
//history.go(1)
//history.back(); // 弹出 "location: http://example.com/example.html?page=1, state: {"page":1}"
//history.back(); // 弹出 "location: http://example.com/example.html, state: null
//history.go(2); // 弹出 "location: http://example.com/example.html?page=3, state: {"page":3}
14.只有标签才能为一个表单但是标签并不能使选择出现下拉,标签,输入等单标签不能:之前的类
15.Vue绑定事件对象用$ event @ click =“fun($ event)”
16.原生AJAX
var ajax=null;
try {
ajax=new XMLHttpRequest()
}catch(e) {
ajax=new ActiveXObject("Microsoft.XMLHTTP")
}
ajax.open("post","a.php",true)
//原生ajax要设置请求头 不然默认text/plain请求头 无法发送键值对数据
ajax.setRequestHeader("content-type","application/x-www-form-urlencoded")
//请求体键值对数据
ajax.send("name=张三&age=20")
ajax.onreadystatechange=function(){
if(ajax.readyState==4){
if(ajax.status==200){
console.log(ajax.responseText)
}
}else{
console.log(ajax.status)
}
}
17.要想在形式提交时不跳到其他页面可以这样!表单提交好像没用到的XMLHttpRequest的的因为在控制台XHR请求里面看不到
<!-- 空iframe,用于协助处理form提交后不进行页面跳转的问题 -->
<form target="iframe_display" action=""></form>
<iframe name="iframe_display" style="display: none;"></iframe>
18.拼接对象用Object.assign({},{})取对象的值Object.values()取对象的键Object.keys()
19.js有几种基本数据类型?用的typeof运算运算去检测的话有基本类型(数字,未定义的,字符串,布尔)引用类型(对象,函数)
阵列是对象,空是物体另外还用日期对象正则对象等等
20.用vue时可以先绑定个原生类名在绑定个vue类名<div class =“text-danger”:class =“'active'”>
21.if判断中undefined,null,0 NaN,“”,false都执行不了
22.Boolean(arr)用来判断布尔值是真还是假
23.iframe获取父页面parent.document操作父方法parent.function(),window.open()打开的窗口可以通过opener.document opener.function()来搞
24.普通函数和定时器中的这是窗口,构造函数中的这是实例对象,原型方法中的这也是实例对象
25.当css定位设置的是绝时离脱离文档流,margin不再生效
26.在3d变换中,如果perspective不生效那可能是不兼容加上-webkit-前缀试验,transform-style:perserve-3d开启3d模式
27.回调函数函数作为参数调用
28.阻止事件冒泡 e.stopPropagation