vue数组中数据变化但是视图没有更新解决方案

数组更新检测

变异方法
Vue 包含一组观察数组的变异方法,所以它们也将会触发视图更新。这些方法如下:

1
2
3
4
5
6
7
push()
pop()
shift()
unshift()
splice()
sort()
reverse()

阅读全文

修改element ui 源码 npm run dist 报错以及解决方案

报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
D:\astudy\element-dev\packages\theme-chalk\src\fonts\element-icons.ttf
1:1 error Parsing error: Unexpected character ''

D:\astudy\element-dev\packages\theme-chalk\src\fonts\element-icons.woff
1:5 error Parsing error: Unexpected character ''

2 problems (2 errors, 0 warnings)

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! element-ui@2.4.1 lint: `eslint src/**/* test/**/* packages/**/* build/**/* --quiet`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the element-ui@2.4.1 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\terry.wt\AppData\Roaming\npm-cache\_logs\2018-06-25T06_12_46_026Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! element-ui@2.4.1 dist: `npm run clean && npm run build:file && npm run lint && webpack --config build/webpack.conf.js && webpack --config build/webpack.common.js && webpack --config build/webpack.component.js
&& npm run build:utils && npm run build:umd && npm run build:theme`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the element-ui@2.4.1 dist script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\terry.wt\AppData\Roaming\npm-cache\_logs\2018-06-25T06_12_46_124Z-debug.log

阅读全文

[react]-动态添加class

1
2
3
4
5
<li className={['mingxi-tit-one', this.state.buttonType === 1 
&& 'mingxi-active'].join(' ')}></li>
// 数组元素为className,
// && 符号为判断符,若条件成立则执行后面的内容
// join为数组的方法,将数组元素拼接为字符串,链接符为一个空字符串

阅读全文

【ElementUI】日期选择器时间选择范围限制插入、替换

ElementUI是饿了么推出的一套基于vue2.x的一个ui框架。官方文档也很详细,这里做一个element-ui日期插件的补充。
官方文档中使用picker-options属性来限制可选择的日期,这里举例子稍做补充。

单个输入框的

阅读全文

详解angularJS动态生成的页面中ng-click无效解决办法

今天碰到了一个这样的需求,在自己写的动态的页面中,写入的AngularJS无效不能点击响应事件,以下给出代码以及解决方案

1.首先将我们要赋值给页面的数据new一下
1
2
3
4
5
6
7
var html = "<a href='javascript:void(0);' ng-click='test()'></a>"
```

<h5>2.用$compile函数编译一下上边的内容</h5>

```html
var $html = $compile(html)($scope);

阅读全文

frank的前端开发规范(逐步完善)

js方法注释规范

规范的注释很重要

代码是写给人看的,顺便给机器运行,多谢注释可以增加代码的可读性

阅读全文

flex水平垂直居中

1
2
3
4
5
.box {
display: flex;
align-items: center;/*垂直居中*/
justify-content: center;/*水平居中*/
}

阅读全文

正则回顾总结

一、简介

1.1 正则表达式的web常见场合

    阅读全文

    emoji表情存储后台报错的问题

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /** 
    * 用于把用utf16编码的字符转换成实体字符,以供后台存储
    * @param {string} str 将要转换的字符串,其中含有utf16字符将被自动检出
    * @return {string} 转换后的字符串,utf16字符将被转换成&#xxxx;形式的实体字符
    */

    utf16toEntities(str) {
    var patt = /[\ud800-\udbff][\udc00-\udfff]/g; // 检测utf16字符正则
    str = str.replace(patt, function(char) {
    var H, L, code;
    if (char.length === 2) {
    H = char.charCodeAt(0); // 取出高位
    L = char.charCodeAt(1); // 取出低位
    code = (H - 0xD800) * 0x400 + 0x10000 + L - 0xDC00; // 转换算法
    return "&#" + code + ";";
    } else {
    return char;
    }
    });
    return str;
    }

    阅读全文

    lazyload页面中间有滚动条,滑动鼠标无法触发图片预加载

    图片在容器里面你可以将插件用在可滚动容器的图片上, 例如带滚动条的 DIV 元素. 你要做的只是将容器定义为 jQuery 对象并作为参数传到初始化方法里面.
    css代码

    1
    2
    3
    4
    # container {
    height: 600px;
    overflow: scroll;
    }

    阅读全文