Coder Social home page Coder Social logo

Comments (7)

yygmind avatar yygmind commented on July 22, 2024

大佬好啊,请问文章可以转载到公众号「高级前端进阶」吗,会注明作者和来源,感谢

from blog.

yacan8 avatar yacan8 commented on July 22, 2024

大佬好啊,请问文章可以转载到公众号「高级前端进阶」吗,会注明作者和来源,感谢

可以的

from blog.

luyukunluyukun avatar luyukunluyukun commented on July 22, 2024

大佬,文中说 template 优先级会高于 render 函数,但我在浏览器运行编写 template 为

hello vue

,render 函数渲染

hello world

,浏览器显示 render 函数的内容,这是什么原因呢

from blog.

yacan8 avatar yacan8 commented on July 22, 2024

大佬,文中说 template 优先级会高于 render 函数,但我在浏览器运行编写 template 为

hello vue

,render 函数渲染

hello world

,浏览器显示 render 函数的内容,这是什么原因呢

vue在runtime时判断到如果组件存在render函数,就不会实时编译template,而是直接使用render函数,所以在runtime时render优先级比template高。
但是组件预编译时,vue-loader的vue-template-compiler会直接忽略组件原有的render函数,然后编译template,将编译后的结果在AST中直接覆盖原有的render函数的引用,所以在预编译阶段,template的优先级比render高。

from blog.

luyukunluyukun avatar luyukunluyukun commented on July 22, 2024

感谢大佬,受教了,请问是否可以理解为直接在配置项中写 template 的形式是 runtime 模式,写 vue 单文件进行预编译的是 runtime-compiler 模式呢,这是我在某课网的教学视频上听到的两个说法,一直没弄懂

from blog.

yacan8 avatar yacan8 commented on July 22, 2024

感谢大佬,受教了,请问是否可以理解为直接在配置项中写 template 的形式是 runtime 模式,写 vue 单文件进行预编译的是 runtime-compiler 模式呢,这是我在某课网的教学视频上听到的两个说法,一直没弄懂

是否经过预编译取决于组件有没有经过vue-loader编译,与是否写在配置项中无关。

from blog.

luyukunluyukun avatar luyukunluyukun commented on July 22, 2024

好的,thanks

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.