第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

為什么不應(yīng)用CSS類(lèi)?

為什么不應(yīng)用CSS類(lèi)?

你能告訴我為什么不應(yīng)用 css 類(lèi)嗎??我imported的 cssexternal文件是這樣的。@import url("https://gist.githubusercontent.com/eirikbakke/1059266/raw/d81dba46c76169c2b253de0baed790677883c221/gistfile1.css");像這樣使用export default function App() {  return (    <div className="someclass">      <h1 className="someclass">Hello CodeSandbox</h1>      <h2>Start editing to see some magic happen!</h2>    </div>  );}這是我的代碼 https://codesandbox.io/s/priceless-turing-x62pz?file=/src/styles.css
查看完整描述

2 回答

?
瀟湘沐

TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超6個(gè)贊

這是因?yàn)橥獠?css 文件被解釋為文本而不是 css 文件

The resource from “https://gist.githubusercontent.com/eirikbakke/1059266/raw/d81dba46c76169c2b253de0baed790677883c221/gistfile1.css” was blocked due to MIME type (“text/plain”) mismatch (X-Content-Type-Options: nosniff


查看完整回答
反對(duì) 回復(fù) 2023-08-18
?
阿波羅的戰(zhàn)車(chē)

TA貢獻(xiàn)1862條經(jīng)驗(yàn) 獲得超6個(gè)贊

我認(rèn)為 GitHub 不允許在其他地方使用其原始托管文件,因此 Github 已阻止來(lái)自跨域的請(qǐng)求。

這是服務(wù)器端配置,您無(wú)法在 Github 服務(wù)器上啟用 CORS。

另一種方法是將文件托管在某些 CDN 中或下載文件并將其保存在本地。

我發(fā)現(xiàn)的另一種選擇是通過(guò) JS 下載文件的內(nèi)容,然后將其附加為樣式元素。

我從未在 React 中工作過(guò),但我相信您更清楚保存下載文件功能的最佳位置。

function loadCssDynamically(fileUrl){

? ? // read text from URL location

? ? var request = new XMLHttpRequest();

? ? request.open('GET', fileUrl, true);

? ? request.send(null);

? ? request.onreadystatechange = function () {

? ? ? ? if (request.readyState === 4 && request.status === 200) {

? ? ? ? ? ? var type = request.getResponseHeader('Content-Type');

? ? ? ? ? ? if (type.indexOf("text") !== 1) {

? ? ? ? ? ? ? ?var style = document.createElement('style');

? ? ? ? ? ? ? ?style.innerHTML = request.responseText;

? ? ? ? ? ? ? ?document.head.appendChild(style);

? ? ? ? ? ? ? ?// console.log(request.responseText);

? ? ? ? ? ? ? ?// return request.responseText;

? ? ? ? ? ? }

? ? ? ? }

? ? }

}


var file = "https://gist.githubusercontent.com/eirikbakke/1059266/raw/d81dba46c76169c2b253de0baed790677883c221/gistfile1.css";

loadCssDynamically(file);


查看完整回答
反對(duì) 回復(fù) 2023-08-18
?
qq_遁去的一_1

TA貢獻(xiàn)1725條經(jīng)驗(yàn) 獲得超8個(gè)贊

重要提示:rawgit.com 即將關(guān)閉。在這里閱讀有關(guān)其他替代方案的更多信息 - https://rawgit.com/

因此,這與您的代碼無(wú)關(guān)。另一種方法是復(fù)制要點(diǎn) url 并將其粘貼到https://raw.githack.com/中,它將提供可用于運(yùn)行示例的鏈接。

我使用你的鏈接來(lái)獲取此鏈接,https://gist.githack.com/eirikbakke/1059266/raw/d81dba46c76169c2b253de0baed790677883c221/gistfile1.css在你的 css 中應(yīng)用此鏈接可以工作。

工作沙箱 [https://codesandbox.io/s/old-paper-lkdse]


查看完整回答
反對(duì) 回復(fù) 2023-08-18
  • 2 回答
  • 0 關(guān)注
  • 183 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)