JavaScript In Vue, what is the relationship of template, render, VNode? what is a relationship template

During development of a vue project, and got some doubt regarding template / render / VNode.

After reading the document https://vuejs.org/v2/guide/syntax.html, and google search, still didn't understand it well.


Code

main.js: (partly)

new Vue({
  el: '#app',
  render: h => h(App),
  router
})

App.vue:

<template>
  <div id="content">
    <!--    <img src="./assets/logo.png" alt="">-->
    <router-view></router-view>
  </div>
</template>

<script>
  export default {}
</script>

Questions

  • What is h from h => h(App) ?
  • And what is the type of h's return value?
  • Does the template always compile to a VNode or a function that returns a VNode?
Answer:1

1) h is an alias to the createElement function as explained at the end of this paragraph.

2) h, or better said the createElement function returns a virtual node, or VNode, a Vue internal representation of a regular HTML element, like a div. You can find more details in the documentation too.

3) Templates compile to the same render functions you were talking about. Here the details. So basically, templates are an high level abstraction to create low level VNodes.

Answer:2

I have the following object: productDetails: { cislife: [], prime: [] } I want to return null instead of empty array if there aren't any values available. e.g: I want to check if any of ...

I have the following object: productDetails: { cislife: [], prime: [] } I want to return null instead of empty array if there aren't any values available. e.g: I want to check if any of ...

  1. loop through object javascript
  2. loop through object keys javascript
  3. loop through object properties
  4. loop through object typescript
  5. loop through object keys
  6. loop through object properties c#
  7. loop through object c#
  8. loop through object array javascript
  9. loop through object react
  10. loop through object es6
  11. loop through object php
  12. loop through object java
  13. loop through object lodash
  14. loop through object angular
  15. loop through object jquery
  16. loop through object python
  17. loop through object javascript es5
  18. loop through object javascript key value
  19. loop through object values
  20. loop through object jsx

So I'm trying to make a function that grabs a HTML element and then after I've selected the HTML element I try to apply CSS to it via JavaScript but it doesn't seem to work. Instead, I get an error ...

So I'm trying to make a function that grabs a HTML element and then after I've selected the HTML element I try to apply CSS to it via JavaScript but it doesn't seem to work. Instead, I get an error ...

  1. javascript function that returns a function
  2. javascript function that returns a value
  3. javascript function that returns a promise
  4. javascript function that does nothing
  5. javascript function that returns boolean
  6. javascript function that accepts array
  7. javascript function that returns array
  8. javascript function that returns an object
  9. javascript function that can be suspended and resumed
  10. javascript function that adds numbers
  11. javascript function that returns nothing
  12. javascript function that only runs once
  13. javascript function that calls another function
  14. javascript function that runs on page load
  15. javascript function that executes immediately
  16. javascript function that takes a string
  17. javascript function that adds two numbers
  18. javascript function that returns html
  19. javascript function that takes an array
  20. javascript function that always runs

I tried to load a page inside my phonegape aplication with Jquery .load() but it doesn't work since it's not on a server and it's on local machine. When I'll upload the app on build. phonegape my ...

I tried to load a page inside my phonegape aplication with Jquery .load() but it doesn't work since it's not on a server and it's on local machine. When I'll upload the app on build. phonegape my ...

  1. phonegap load local html file
  2. phonegap load local file

I need to input this code through CKEditor: <ruby>niroj adhikary<rp>(</rp><rt>this is name</rt><rp>)</rp></ruby> CKEditor is not accepting ...

I need to input this code through CKEditor: <ruby>niroj adhikary<rp>(</rp><rt>this is name</rt><rp>)</rp></ruby> CKEditor is not accepting ...