Skip to content

Commit 0338b63

Browse files
committed
merge Allow dynamic values in v-link #9
2 parents 0ed4540 + 6e92388 commit 0338b63

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/link.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,26 @@ module.exports = function (Vue) {
55

66
Vue.directive('link', {
77

8+
isLiteral: true,
9+
810
bind: function () {
9-
var vm = this.vm
10-
var href = this.expression
11-
if (this.el.tagName === 'A') {
12-
this.el.href = href
13-
}
11+
var self = this
1412
this.handler = function (e) {
1513
e.preventDefault()
16-
vm.route._router.go(href)
14+
self.vm.$root.route._router.go(self.destination)
1715
}
1816
this.el.addEventListener('click', this.handler)
1917
},
2018

2119
unbind: function () {
2220
this.el.removeEventListener('click', this.handler)
21+
},
22+
23+
update: function (value) {
24+
this.destination = value
25+
if (this.el.tagName === 'A') {
26+
this.el.href = value
27+
}
2328
}
2429

2530
})

0 commit comments

Comments
 (0)