Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit828b32b

Browse files
author
undefined
committed
fix: unbind before bind case
1 parent20076f2 commit828b32b

File tree

2 files changed

+48
-41
lines changed

2 files changed

+48
-41
lines changed

‎index.js‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ Object.defineProperty(exports, "__esModule", {
55
});
66
exports.default={
77
install:functioninstall(Vue){
8-
varoptions=arguments.length>1&&arguments[1]!==undefined ?arguments[1] :{};
9-
vardirectiveName=options.name||'ref';
8+
varoptions=
9+
arguments.length>1&&arguments[1]!==undefined ?arguments[1] :{};
10+
vardirectiveName=options.name||"ref";
1011
Vue.directive(directiveName,{
1112
bind:functionbind(el,binding,vnode){
13+
Vue.nextTick(function(){
14+
binding.value(vnode.componentInstance||el,vnode.key);
15+
});
1216
binding.value(vnode.componentInstance||el,vnode.key);
1317
},
1418
update:functionupdate(el,binding,vnode,oldVnode){
1519
if(oldVnode.data&&oldVnode.data.directives){
16-
varoldBinding=oldVnode.data.directives.find(function(directive){
20+
varoldBinding=oldVnode.data.directives.find(function(directive){
1721
varname=directive.name;
1822
returnname===directiveName;
1923
});
@@ -24,7 +28,10 @@ exports.default = {
2428
}
2529
}
2630
// Should not have this situation
27-
if(vnode.componentInstance!==oldVnode.componentInstance||vnode.elm!==oldVnode.elm){
31+
if(
32+
vnode.componentInstance!==oldVnode.componentInstance||
33+
vnode.elm!==oldVnode.elm
34+
){
2835
binding.value(vnode.componentInstance||el,vnode.key);
2936
}
3037
},
@@ -33,4 +40,4 @@ exports.default = {
3340
}
3441
});
3542
}
36-
};
43+
};

‎package.json‎

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
11
{
2-
"name":"vue-ref",
3-
"version":"1.0.6",
4-
"title":"Vue Ref",
5-
"description":"use the callback to get a reference like react",
6-
"keywords": [
7-
"vue",
8-
"ref",
9-
"v-ref",
10-
"vue-ref"
11-
],
12-
"main":"index.js",
13-
"files": [
14-
"index.js"
15-
],
16-
"repository": {
17-
"type":"git",
18-
"url":"git+https://github.com/tangjinzhou/vue-ref.git"
2+
"name":"vue-ref",
3+
"version":"2.0.0",
4+
"title":"Vue Ref",
5+
"description":"use the callback to get a reference like react",
6+
"keywords": [
7+
"vue",
8+
"ref",
9+
"v-ref",
10+
"vue-ref"
11+
],
12+
"main":"index.js",
13+
"files": [
14+
"index.js"
15+
],
16+
"repository": {
17+
"type":"git",
18+
"url":"git+https://github.com/tangjinzhou/vue-ref.git"
19+
},
20+
"license":"MIT",
21+
"bugs": {
22+
"url":"https://github.com/tangjinzhou/vue-ref/issues"
23+
},
24+
"homepage":"https://github.com/tangjinzhou/vue-ref",
25+
"eslintConfig": {
26+
"root":true,
27+
"env": {
28+
"node":true
1929
},
20-
"license":"MIT",
21-
"bugs": {
22-
"url":"https://github.com/tangjinzhou/vue-ref/issues"
23-
},
24-
"homepage":"https://github.com/tangjinzhou/vue-ref",
25-
"eslintConfig": {
26-
"root":true,
27-
"env": {
28-
"node":true
29-
},
30-
"extends": [
31-
"plugin:vue/essential",
32-
"eslint:recommended"
33-
],
34-
"rules": {},
35-
"parserOptions": {
36-
"parser":"babel-eslint"
37-
}
30+
"extends": [
31+
"plugin:vue/essential",
32+
"eslint:recommended"
33+
],
34+
"rules": {},
35+
"parserOptions": {
36+
"parser":"babel-eslint"
3837
}
39-
}
38+
}
39+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp