Я создал форму создания, используя Node, Express и Jade шаблон. Но моя страница создания не использует основной макет, который я создаю. Я расширяю основной макет, он работает на моей странице списка сотрудников, но не работает на странице создания. он показывает только HTML, а не CSS или начальную загрузку. пожалуйста, помогите.
Вот структура моего сайта.
Мой главный.jade:
doctype html
html(lang='en')
head
include htmlheader.jade
body.page-body.hold-transition.skin-blue.sidebar-mini(style='background: #d2d6de')
//- | @section('htmlheader')
//- include layouts/partials/htmlheader.jade
//- | @include('layouts.partials.htmlheader')
// this page specific styles
//- | @show
#fb-root
.page-container
.main-content.main-header
include sidebar.jade
include pageheader.jade
block content
// Sample Modal (Default skin)
include footer.jade
//- | @include('layouts.partials.footer')
// Theme Scripts
Мой route.js:
var express = require('express');
var router = express.Router();
var employee = require("../controllers/EmployeeController.js");
// Get all employees
router.get('/', employee.list);
// Get single employee by id
router.get('/show/:id', employee.show);
// Create employee
router.get('/create', employee.create);
// Save employee
router.post('/save', employee.save);
// Edit employee
router.get('/edit/:id', employee.edit);
// Edit update
router.post('/update/:id', employee.update);
// Edit update
router.post('/delete/:id', employee.delete);
module.exports = router;
Мой create.jade:
extends ../layout/main
block content
body
.container
h3
a(href='/employees') Employee List
//- a.btn.btn-success(href="/employees") Employee List
h1 Create New Employee
form(action='/employees/save', method='post')
.form-group
label(for='name') Name*
.col-md-10
input#name.form-control(type='text', name='name', placeholder='Name')
.form-group
label(for='address') Address*
.col-md-10
input#address.form-control(type='text', name='address', placeholder='Address')
.form-group
label(for='position') Position*
.col-md-10
input#position.form-control(type='text', name='position', placeholder='Position')
.form-group
label(for='salary') Salary*
.col-md-10
input#salary.form-control(type='text', name='salary', placeholder='Salary')
button.btn.btn-default(type='submit') Create
Когда я попробую это http://localhost:3000/employees/create, это покажет это
Мой index.jade:
extends ../layout/main
block content
body
.container
h3
a(href='/employees/create') Create Employee
h1 Employee List
//- if employee.length>0
//- for(var i=0 i<employee.length i++)
table.table.table-striped
thead
tr
th Employee Name
th Position
tbody
tr
//- td
//- a(href='/employees/show/#{employee[i]._id}') #{employee[i].name}
td Moaiz
//- td #{employee[i].position}
td Software Developer
//- div No employees found.
А в index.jade я использую тот же макет, и он покажет так:
Пожалуйста, помогите, где я могу что-то пропустить или сделать что-то не так.
Edit:
Я думаю, проблема в том, что это не правильный путь.
Вот изображение:
Когда я нажимаю "Создать сотрудника", путь начинается с employees
. И я не могу найти, почему он включает в себя employees
в пути. Я думаю, что это проблема, поэтому он не может правильно отображать макет. До попадания на create
, которое вы видели на изображении, оно не включает employees
в пути. Пожалуйста, помогите мне найти решение.
Вот мой htmlheader.jade :
head
meta(http-equiv='X-UA-Compatible', content='IE=edge')
meta(charset='utf-8')
meta(name='viewport', content='width=device-width, initial-scale=1')
meta(name='description', content='Admin Dashboard')
meta(name='author', content='')
meta(property='og:type', content='website')
meta(property='og:title', content='')
meta(property='og:description', content='')
meta(property='og:image', content='')
// CSRF Token
meta(name='csrf-token', content='{{ csrf_token() }}')
//- | {{--
//- title {{ config('app.name', 'Admin Dashboard') }}
//- | --}}
title Admin Dashboard
// Styles
script(src="{{url('dist/js/jquery-1.11.3.min.js')}}")
link(rel='stylesheet', href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic')
//- | {{--
//- link(rel='stylesheet', href="{{url('assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css')}}")
//- | --}}
meta(content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no', name='viewport')
// Bootstrap 3.3.7
link(rel='stylesheet',
href="bower_components/bootstrap/dist/css/bootstrap.min.css")
// Font Awesome
link(rel='stylesheet', href="bower_components/font-awesome/css/font-awesome.min.css")
// Ionicons
link(rel='stylesheet', href="bower_components/Ionicons/css/ionicons.min.css")
// jvectormap
link(rel='stylesheet', href="bower_components/jvectormap/jquery-jvectormap.css")
// Theme style
link(rel='stylesheet', href="dist/css/AdminLTE.min.css")
//
AdminLTE Skins. Choose a skin from the css/skins
folder instead of downloading all of them to reduce the load.
link(rel='stylesheet', href="dist/css/skins/_all-skins.min.css")
link(rel='stylesheet', href="bower_components/morris.js/morris.css")
link(rel='stylesheet', href="bower_components/jvectormap/jquery-jvectormap.css")
// Date Picker
link(rel='stylesheet', href="bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css")
// Daterange picker
link(rel='stylesheet', href="bower_components/bootstrap-daterangepicker/daterangepicker.css")
// bootstrap wysihtml5 - text editor
link(rel='stylesheet', href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css")
// HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries
//if lt IE 9
script(src='https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js')
script(src='https://oss.maxcdn.com/respond/1.4.2/respond.min.js')
block custom_styles