<div class="card">
<h5 class="card-header">Featured</h5>
<div class="card-body">
<h5 class="card-title">Special title treatment</h5>
<p class="card-text">With supporting text below as a natural lead-in to additional content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
<!-- 訊息盒子
content += render('tmp_message', {tmp_class: 'card-header bg-primary text-white', title: '成功訊息盒子', message: '訊息'});
content += render('tmp_message', {tmp_class: 'card-header bg-danger text-white', title: '失敗訊息盒子', message: '訊息'});
-->
<!-- tmp_class='card-header'、title、message -->
<div class="card">
<div class="<?= tmp_class ?>">
<?= title ?>
</div>
<div class="card-body">
<p class="card-text">
<?= message ?>
</p>
</div>
</div>
content += render('tmp_message', {tmp_class: 'card-header bg-primary text-white', title: '成功訊息盒子', message: '訊息'});
/*=====================================
首頁
=====================================*/
function index(e) {
let title = '首頁';
let content = '';
content = `<h2 class='mt-3'>${title}</h2>`;
content += render('tmp_message', {tmp_class: 'card-header bg-primary text-white', title: '訊息盒子', message: '訊息'});
content += render('tmp_message', {tmp_class: 'card-header bg-danger text-white', title: '訊息盒子', message: '訊息'});
return render('tmp', {content: content}, title);
}
結果畫面
至官網取得button元件,儲存為 tmp_button.html
<button type="button" class="btn btn-primary">Primary</button>
<button type="button" class="btn btn-secondary">Secondary</button>
<button type="button" class="btn btn-success">Success</button>
<button type="button" class="btn btn-danger">Danger</button>
<button type="button" class="btn btn-warning">Warning</button>
<button type="button" class="btn btn-info">Info</button>
<button type="button" class="btn btn-light">Light</button>
<button type="button" class="btn btn-dark">Dark</button>
<button type="button" class="btn btn-link">Link</button>
<!-- tmp_button.html 按鈕 -->
<a class='<?= tmp_class ?>' href='<?!= url ?>' target='<?= target ?>'><?= title ?></a>
<!-- 按鈕
btn-secondary
btn-warning
btn-info
btn-light
btn-dark
btn-link
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-primary', title: '新增', url: global.url+'?op=xxx', target: "_blank"});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-success', title: '編輯', url: global.url+'?op=xxx&sn=', target: "_blank"});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-danger', title: '刪除', url: global.url+'?op=xxx&sn=', target: "_blank"});
-->
<a href="<?= url ?>" class="<?= tmp_class ?>" target="<?= target ?>"><?= title ?></a>
/*=====================================
首頁
=====================================*/
function index(e) {
let title = '首頁';
let content = '';
content = `<h2 class='mt-3'>${title}</h2>`;
// ---------------------------------訊息盒子
content += render('tmp_message', {tmp_class: 'card-header bg-primary text-white', title: '成功訊息盒子', message: '訊息'});
content += render('tmp_message', {tmp_class: 'card-header bg-danger text-white', title: '失敗訊息盒子', message: '訊息'});
// ---------------------------------按鈕
content += '<div class="mt-5">';
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-primary', title: '新增', url: global.url+'?op=xxx', target: "_blank"});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-success', title: '編輯', url: global.url+'?op=xxx&sn=', target: "_blank"});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-danger', title: '刪除', url: global.url+'?op=xxx&sn=', target: "_blank"});
content += '</div>';
return render('tmp', {content: content}, title);
}
結果畫面
// ---------------------------------回傳訊息
let content = '';
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-primary', title: '新增', url: global.url+'?op=form_custom', target: ""});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-success', title: '編輯', url: global.url+'?op=form_custom&sn='+formData.sn, target: ""});
content += render('tmp_button', {tmp_class: 'btn btn-xs btn-secondary', title: '回首頁', url: global.url, target: ""});
return content;