holdtom
2023-07-06 14:52:16
我有一個(gè)角度前端項(xiàng)目,我有一個(gè)儀表板組件,里面有一個(gè)側(cè)邊欄,但代碼的腳本標(biāo)簽和 html 在同一個(gè)文件中。我想將它們分開以減少代碼。我嘗試將這些腳本與路徑包含在我的 angular.json 中,但它沒有被識(shí)別,而且我不知道我還可以嘗試什么。我的 html 代碼如下所示,我想將 Head 標(biāo)簽和 script 標(biāo)簽分開。<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"><script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script><script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script><!------ Include the above in your HEAD tag ----------><!DOCTYPE html><html><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="Responsive sidebar template with sliding effect and dropdown menu based on bootstrap 3"> <title>Sidebar template</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <link href="https://use.fontawesome.com/releases/v5.0.6/css/all.css" rel="stylesheet"></head><moniesta-client-navbar></moniesta-client-navbar><body><div class="page-wrapper chiller-theme toggled"> <a id="show-sidebar" class="btn btn-sm btn-dark" href="#"> <i class="fas fa-bars"></i> </a> <nav id="sidebar" class="sidebar-wrapper"> <div class="sidebar-content"> <div class="sidebar-brand"> <a href="#">pro sidebar</a> <div id="close-sidebar"> <i class="fas fa-times"></i> </div> </div> <div class="sidebar-header"> <div class="user-pic"> <img class="img-responsive img-rounded" src="https://raw.githubusercontent.com/azouaoui-med/pro-sidebar-template/gh-pages/src/img/user.jpg" alt="User picture">
1 回答

牛魔王的故事
TA貢獻(xiàn)1830條經(jīng)驗(yàn) 獲得超3個(gè)贊
您需要安裝這些軟件包。這里你的腳本中有包。
npm i jquery
npm i bootstrap
npm i @fortawesome/angular-fontawesome
https://github.com/FortAwesome/angular-fontawesome
并且不要忘記bootstrap在jqueryangular.json
"styles": [
"src/styles.css",
"node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.min.js",
"node_modules/bootstrap/dist/js/bootstrap.min.js"
]
我建議您將代碼分成不同的組件。這就是讓你的代碼更具可讀性,并且可以更快地修復(fù)錯(cuò)誤或找到你想要的東西。
添加回答
舉報(bào)
0/150
提交
取消