Vuejs append data-attribute conditionally Vuejs append data-attribute conditionally vue.js vue.js

Vuejs append data-attribute conditionally


Use : before that and I would create a computed property like this.

computed: {     parentId() {       if (this.model.parent_id !== null)          return this.model.parent_id       return 0;     }}<ul :data-parent="parentId"></ul>


The right Syntax

<ul :data-parent="{{(model.parent_id !== null) ? model.parent_id : 0}}"></ul>