Skip to content

Commit aad1d40

Browse files
committed
convert vue-toastr to use render function
1 parent ff0a202 commit aad1d40

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/vue-toastr.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
1-
import template from './vue-toastr.html'
21
import toast from './toast/toast.js'
32
export default {
4-
template: template,
3+
render: function (createElement) {
4+
var toastContainers = []
5+
for (var i = 0; i < this.positions.length; i++) {
6+
var position = this.positions[i]
7+
var toastNodes = []
8+
9+
var listKeys = Object.keys(this.list[position])
10+
for (var j = 0; j < listKeys.length; j++) {
11+
var index = listKeys[j]
12+
toastNodes.push(createElement('toast', {
13+
props: {
14+
data: this.list[position][index]
15+
},
16+
key: index
17+
}))
18+
}
19+
20+
toastContainers.push(createElement('div', {
21+
class: 'toast-container ' + position,
22+
key: position
23+
}, toastNodes))
24+
}
25+
return createElement('div', toastContainers)
26+
},
527
name: 'vueToastr',
628
props: ['options'],
729
data () {

0 commit comments

Comments
 (0)