基本上,我正在創建一個簡單的宣傳冊網站,可以使用 Javascript 動態更改內容。每次單擊按鈕時,它都會調用 .js 文件中的一個函數,將其插入到 html 中。為此,我將這些數據放入 .js 文件中的一個變量中。問題是我發現數據太大并且使 .js 文件混亂。<button class="content-1"><button class="content-2"><div class="container"> # change between content 1 and 2</div>// in my case there are more than 2 contents// each content has other contents as well// the question is where to put these data let contentOne = [ "a lot of text data", "a lot of text data", "a lot of text data"]# other code現在我設法將它們分離到另一個 .js 文件中。但我只是想知道,是否有一種更簡潔的方式來存儲然后訪問這些數據?喜歡使用 YAML 嗎?你通常是怎么做的?對于動態網站,我知道它通常存儲在數據庫中,但是對于靜態網站來說呢?
在 html 中存儲動態內容數據的最佳做法是什么?
幕布斯6054654
2022-12-02 10:47:33