admin管理员组文章数量:1144901
i have made some blocks before with @wordpress/create-block now i wanted to work on a new block, and it seem there is a new file: view.js.
i have searched the web and ducomentation in the handbook, and maybe i am missing something, but couldn't find anything on it.is it there for custom javascript code ? is it only applicable for the front end?
so what is the view.js file for?
best regards
i have made some blocks before with @wordpress/create-block now i wanted to work on a new block, and it seem there is a new file: view.js.
i have searched the web and ducomentation in the handbook, and maybe i am missing something, but couldn't find anything on it.is it there for custom javascript code ? is it only applicable for the front end?
so what is the view.js file for?
best regards
Share Improve this question asked Nov 8, 2023 at 7:42 RonRon 1657 bronze badges1 Answer
Reset to default 1The filename is not really relevant. You should check block.json to see where the file is actually being used. I would guess that it's being used for the viewScript
property, in which case you can check its purpose by looking for the documentation for that property, rather than anything about "view.js" alone.
As noted in the documentation, the viewScript
file is a script that will be loaded on the front end when the block is used. This is where any interactivity your block might have would be implemented if it's not relevant in the editor.
本文标签: block editorwhat is the function of the viewjs file
版权声明:本文标题:block editor - what is the function of the view.js file? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736755535a1951265.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论