The main page index.html is like this
<body>
<p id="container">
</p>
<script src="js/main.js"></script>
</body>
Page page_1.html For the convenience of operation, there is only dom block and no Body html tag
<p class="page_1">
page_1
</p>
There are many such sub-pages page_2.html, page_3.html, page_4.html...
<p class="page_2">
page_2
</p>
<p class="page_3">
page_3
</p>
Now I want to add the content of page_1.html page_3.html to the <p id="container"> of index.html as needed. The execution environment can be react.js and the backend is added. .
Seeking popular science
怪我咯2017-05-18 10:48:55
I don’t know about react. For jquery, just use load(). I guess loading through ajax is also possible. However, there are a few points to pay attention to:
1. It cannot be cross-domain.
2. Be sure to use it when calling the path. Address with domain name, such as changing $.get("page_1.html") to $.get("http://xxxxxxx/page_1.html")
This should be enough
天蓬老师2017-05-18 10:48:55
Isn’t this what React itself is doing?
<p id="container">
{(condition) ? <Page1> : <Page2>}
</p>
The above code only expresses a meaning, and the judgment part can be more complicated. "Pages" are all modules, which can be loaded according to conditions.