Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
372 views
in Technique[技术] by (71.8m points)

express - Is it possible to render a part of a website, using vanilla JavaScript instead of react.js?

I am learning web development, and I found that to render a change in a web-site, we will have to make a request to the server (say it's built using express.js), and the server will render the new page, from the EJS templates provided. But in this case, whenever a change has to be reflected on the client-side, the entire web-page must be received and rendered in the browser.

I want to know if there is a way in the vanilla JS, through which I can render only a part of the page, instead of rendering the complete page again and again?

Thank you!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Yes, you can. Check this video. It's an ecommerce tutorial using javascript only in a ...react-kinda-way. The same guy has another one where he builds the exact same project but with React. So you can compare both methods.

Basic structure is

const layoutComponent = {
render: async () => {
...function content
}
return `
<div> things </div>
and html stuff
`

https://www.youtube.com/watch?v=N3FDyheHVMM&t=8349s


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...