vue render code example

Example 1: vue list render in

<ul id="example-1">
  <li v-for="item in items" :key="item.message">
    {{ item.message }}
  </li>
</ul>

Example 2: vue component: { render:

// ====================================================================
//    Routes
// ====================================================================
          {
            path: '/',
            name: 'home',
            component: () => import('./views/Dashboard.vue'),
          },
// ====================================================================
//    Grouped User Routes
// ====================================================================
          {
            path: '/user',
            name: 'user',
            component: { render: h => h('router-view') }, 
              // renders a router-view so no other component is needed.
            children: [
              {
                path: 'list',
                name: 'user.list',
                component: () => import('./views/pages/User/List.vue'),
              },
            ]
          },
        ],
      
/*
Aliasing createElement to h is a common convention you’ll see in 
the Vue ecosystem and is actually required for JSX. Starting with 
version 3.4.0 of the Babel plugin for Vue, we automatically inject 
const h = this.$createElement in any method and getter (not functions 
or arrow functions), declared in ES2015 syntax that has JSX, so you 
can drop the (h) parameter. With prior versions of the plugin, your app 
would throw an error if h was not available in the scope.
https://vuejs.org/v2/guide/render-function.html
*/

Example 3: get object from list of objects in vuejs with condition

var data = {specs:[{Name:"Power",Value:"1"},{
    Name:"Weight",Value:"2"},{Name:"Height",Value:"3"}]}
    
var valObj = data.specs.filter(function(elem){
    if(elem.Name == "Power") return elem.Value;
});

if(valObj.length > 0)
    console.log(valObj[0].Value)