riophae / vue-treeselect

A multi-select component with nested options support for Vue.js
https://vue-treeselect.js.org/
MIT License
2.89k stars 508 forks source link

get selected values #529

Open gazteaukera opened 1 year ago

gazteaukera commented 1 year ago

I have the following code to populate a vue-treeselect from a json file. I need to save the options that the user has selected in localStorage, and get them selected again when the page is reloaded.

Vue.component("treeselect", VueTreeselect.Treeselect); var tree = new Vue({ el: "#app", data: { value: null, clearOnSelect: true, closeOnSelect: true, flat: true, sortValueBy: 'ORDER_SELECTED', options: [], }, methods: { normalizer: function(node) { return { id: node.id, label: node.label, children: node.children, }; }, }, mounted() { let vm = this;

    $.getJSON("/categories.json", function(json) {
        vm.options = json;
    });
},

});