1611863340
slot
to customize look of node, like icons with images etc. (Will have to look into slot
a bit more)Any future suggestions are welcome
Install the package into your project:
npm install --save @ll931217/vue-treeview
or
yarn add @ll931217/vue-treeview
Add this to your main.js
file:
import Vue from 'vue'
import TreeView from '@ll931217/vue-treeview'
Vue.use(TreeView)
Then add this to where you want to use the treeview:
<tree-view :tree="tree">
The treeview takes in the prop tree
, which is in the following structure:
[
{
"text": "Dogs",
"nodes": [{
"text": "Germany",
"nodes": [{
"text": "American Eskimo Dog",
"nodes": [{
"text": "Fluffy",
"link": {
"type": "link", // Type `link` will create an `Anchor` tag
"value": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/fe/American_Eskimo_Dog_1.jpg/1920px-American_Eskimo_Dog_1.jpg" // URL of the link
}
}]
}, {
"text": "Bavarian Mountain Hound"
}, {
"text": "Boxer",
"nodes": [{
"text": "Rip (Router-link)",
"link": {
"type": "router-link", // Type `router-link` will create a router-link, duh.
"key": "path", // key to use when giving it the value, router-link(:to="{ path: '/d-ger-boxer-rip' }")
"value": "/d-ger-boxer-rip"
}
}, {
"text": "Mackenzie (Router-link)",
"link": {
"type": "router-link",
"key": "name",
"value": "d-ger-boxer-machenzie"
}
}]
}, {
"text": "Bullenbeisser"
}, {
"text": "Deutsche Bracke",
"nodes": [{
"text": "Mini",
"link": {
"type": "link",
"value": "https://animalsbreeds.com/wp-content/uploads/2015/07/Deutsche-Bracke.jpg"
}
}]
}]
}, {
"text": "France",
"nodes": [{
"text": "Ariegeois"
}, {
"text": "Artois Hound"
}]
}]
}, {
"text": "Cats",
"nodes": [
{
"text": "Russia",
"nodes": [{
"text": "Donskoy"
}, {
"text": "Kurilian Bobtail"
}]
}, {
"text": "Thailand",
"nodes": [{
"text": "Khao Manee"
}, {
"text": "Suphalak",
"nodes": [{
"text": "Moon",
"link": {
"type": "link",
"value": "https://www.pets4homes.co.uk/images/articles/4198/what-is-a-suphalak-cat-5947aefcd4845.jpg"
}
}]
}]
}
]
},
{ // >= v0.3.0
"text": "Standing Up",
"link": {
"type": "router-link",
"key": "path",
"value": "templink"
},
"icon": "cube",
"nodes": [
{
"text": "mixamo.com",
"link": {
"type": "router-link",
"key": "path",
"value": "templink"
},
"icon": "running"
}
]
}
]
If you want to use custom icons, you can select them from FontAwesome 5, add them like this:
First download their packages (Solid icons are already available):
Prop | Type | Required |
---|---|---|
tree | Array |
True |
icons | String |
Object |
<template>
<div id="app">
<treeview :tree="tree" :icons="icons" />
</div>
</template>
<script>
import { faChessQueen } from '@fortawesome/free-solid-svg-icons'
import Tree from './tree.json
export default {
name: 'App',
data () {
return {
tree: Tree,
icons: {
closed: 'angle-up',
opened: 'angle-down',
default: faChessQueen
}
}
}
}
</script>
In your node, add an icon
object, you can customise the icon for that specific node such as:
{
"text": "Barbet",
"icon": "surprise"
}
Usage:
<treeview :tree.sync="tree" :editable="true" :show-parent-icon="{ parentShow: true, emptyParentShow: false }" />
The above example will show all icons of parent nodes that has children nodes and hide all empty parent nodes.
NOTE: the prop show-parent-icon
can be written as above or showParentIcon
, its all up to you.
Default:
showParentIcon: {
type: Object,
default: () => ({
parentShow: false,
emptyParentShow: false
})
}
NOTE: Parent nodes with link
property will still show their icon. See the JSON
tree above, the last object tree, the parent node has link
property.
<treeview :tree.sync="tree" :editable="true" :draggable="true" />
Adding .sync
to :tree
would allow two-way binding for the tree data, if data changed in the child component it will be updated for the entire tree, this feature is good for if you want to save the tree if it changed:
<treeview :tree.sync="tree" />
Double-click the parent node will allow you to add new node to the tree, only if editable
prop is passed with the boolean
value of true
:
<treeview :tree.sync="tree" :editable="true" />
This prop
can be used for checking user accounts:
<treeview :tree.sync="tree" :editable="userAccount === 'ADMIN'" />
Author: ll931217
Demo: https://ll931217.github.io/vue-treeview/
Source Code: https://github.com/ll931217/vue-treeview
#vue #vuejs #javascript
1594024630
Want to Hire VueJS Developer to develop an amazing app?
Hire Dedicated VueJS Developers on the contract (time/project) basis providing regular reporting about your app. We, at HourlyDeveloper.io, implement the right strategic approach to offer a wide spectrum of vue.js development services to suit your requirements at most competitive prices.
Consult with us:- https://bit.ly/2C5M6cz
#hire dedicated vuejs developers #vuejs developer #vuejs development company #vuejs development services #vuejs development #vuejs developer
1589190180
In this post, I will explain you now how to publish your own VueJs component on npm with a minify and ES5 build.
#vuejs-development #vuejs-2 #vuejs #github #npm
1599289468
In VueJS there are few ways to compose components and reuse logic. In this article, I would like to demonstrate a way to boost composition in Vuejs (2.* and 3.*).
I really like the recent proposals regarding the Composition API, but I think that can be part of a broader view.
Below, you can find a component implementing a general use case (a simple data fetching from a remote endpoint and displaying the different transitions and data), though most of the logic is always duplicated along with the template, data, and other variables when the same logic is applied to other places or components.
<template>
<div>
<div v-if="loading"> Loading... </div>
<div v-if="error"> An Error occured, please try again</div>
<div v-if="hasData"> {{ data }} </div>
</div>
</template>
</template>
<script>
export default {
data() {
return {
loading: false,
error: false,
data: {}
}
},
methods: {
fetchData() {
this.loading = true;
setTimeout(() => {
this.data = { text: 'example' };
this.loading = false;
}, 4000);
}
},
computed: {
hasData() {
return this.data && !!this.data.text;
}
},
mounted() {
this.fetchData();
}
}
</script>
How do we refactor this component and improve it? Let’s go step-by-step and make this component more readable and reusable.
#functional #components #vuejs #jsx #composition #vue
1599030441
An amazing conference regarding the Vue framework was held in the US in the first week of March 2020 for two fantastic days. Some spectacular presentations were given during that time regarding the design, feature, and application tools of the framework. One of the most eye gazing things was that combining vue.js development services, professionals, and others as there were more than 900 attendees at the event. The brand new composition API for the Vue3 was the talk of the town.
All this leads to the conclusion that Vue might have an opportunity to be the most amazing for the year 2020. While the first quarter has been significantly better for it, let’s look at some of the characteristics which make the Vue an amazing framework for 2020.
Ask any Vue.js developer and they will tell you that how working with this framework is very relaxing and even if you are a beginner, fundamental knowledge of HTML, CSS, and Javascript is good enough to build a simple application.
Do you know more than 75% of Vue.js development services just prefer it because of its ease of integration? This means you can hire Vue.js developers to build the application right from the scratch or can get an existing application accommodated to your requirements.
Although the inbuilt guide and documentation of the Vue framework make it sufficient for you to start coding.
This might interest you to know that Vue.js is for progressive web applications which also support libraries like Vue router, Vuex, Vue Test Utils, Vue-dev tools, Vue CLI for performing various functions.
It may seem a bit exaggerated but the truth is whether its loader, renderer, component caching or asset preload, etc every tool, every component in this framework performs very efficiently.
As noted above how Vue.js development services state that creating an application with Vue is very simple. So now we are going to look briefly into some of the top reasons why Vue.js development companies favor it from the stack of all JS-based frameworks.
Adaptable development environment: Very beneficial to the large scale projects, now and again Vue.js has proved that it adjusts with the components of other applications and develops it in remarkably less time compared to other JS-frameworks. Have you wondered why people are using it comprehensively?
Supported Libraries: Vue.js provides support libraries for any possible difficulties a developer might face. As Vue Router is for routing, Vuex for state management, Vue Test Utils for unit testing, Vue-dev tools for debugging, and Vue CLI for plugin management. And the best part here is this all inbuilt are accessible 24/7. Vue.js developer can rectify or alter the coding with the help of these support libraries.
Great Performance: For developing mobile apps, this framework tends to perform well in comparison to other frameworks. The speed of the loading page is significantly better than any other Javascript. Whether it’s a website or any other application, reliability and great performance is always the best advantage of the framework.
Community meets: Live events or meetings are organized regularly so that the Vue.js developer can get the regular updates of the features and benefits of the framework. This community is growing bigger day by day and is managed by Evan You, the developer of Vue.js framework himself.
#vue #vuejs-development-company #vuejs-developer #vuejs #vuejs-development
1617082992
The JavaScript framework that has grabbed the attention of New Age Website and App developers for its ease of developing interactive elements is the VueJS framework.
Want an elegant and interactive app for your business with VueJS?
Hire dedicated VueJS developers from WebClues Infotech as they have the knowledge, skills, and past experience in developing successful apps with the use of the VueJS framework. Also, do not worry much about the prices as they offer quite a flexible pricing structure and an option to choose the best suitable one for you.
Give your business the boost it needs with the mobile app development.
Hire VueJS developers Now: https://www.webcluesinfotech.com/hire-vuejs-developer/
Email: sales@webcluesinfotech.com
#hire dedicated vuejs developers #hire vuejs developer #hire vuejs developers #hire vue.js developer #hire vuejs developers in india #hire vue.js development company