React.js | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

React.js

В момент создании React.js в файлах есть index.js и index.html, и всё что пишешь в index.js то это отправляется на div с id-root. Но только работает с index.html. У меня есть ещё несколько страниц например films.html и как мне сделать чтобы там работать с React???

20th May 2022, 3:12 PM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar
10 Answers
0
Դանիել Գրիգորյան this is your question, right? At the time of creating React.js, the files have index.js and index.html, and everything you write in index.js is sent to the div with id-root. But only works with index.html. I have some more pages like films.html and how can I make it work with React??? You can create a div with id 'root ' in film.html file, if you no longer need index.html make sure you delete the root id in index.html
21st May 2022, 10:14 AM
ShadowCipher
ShadowCipher - avatar
0
Index.html моя главная страница, но есть ещё и другие страницы, и я хочу использовать во всех страницах. Например на films.html, person.html, comics.html. но я не могу просто "root" подключать их, потому что так не работает.
21st May 2022, 10:19 AM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar
0
Can you write the film.html in javascript as a component and then import it to your main render ?
21st May 2022, 10:23 AM
ShadowCipher
ShadowCipher - avatar
0
Thats another option
21st May 2022, 10:23 AM
ShadowCipher
ShadowCipher - avatar
0
Как мне это сделать?
21st May 2022, 10:25 AM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar
0
const Film = () => { return <> // your codes from film.index goes here </> }
21st May 2022, 10:31 AM
ShadowCipher
ShadowCipher - avatar
0
Код очень длинный, и там ещё отдельно CSS есть.
21st May 2022, 10:34 AM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar
0
Мне весь html код писать там?
21st May 2022, 10:34 AM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar
0
Css is no big deal, you can import the css the file
21st May 2022, 11:37 AM
ShadowCipher
ShadowCipher - avatar
0
Но куда импортировать то? В index.html?
21st May 2022, 12:07 PM
Դանիել Գրիգորյան
Դանիել Գրիգորյան - avatar