Vue便簽的簡單實(shí)現(xiàn)
html部分
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>小錢便簽</title>
<!-- 引入自定義樣式表 -->
<link rel="stylesheet" type="text/css" href="index.css" rel="external nofollow" />
</head>
<body>
<!-- 主體區(qū)域 -->
<section id="app">
<!-- 輸入框 -->
<header>
<h1 class="title">便簽</h1>
<input type="text" v-model="inputValue" autofocus="autofocus"
placeholder="請(qǐng)輸入事項(xiàng)" autocomplete="off" class="new-todo"
@keyup.enter="add"/>
</header>
<!-- 列表區(qū)域 -->
<section class="main">
<ul class="todo-list">
<li class="todo" v-for="(item, index) in list">
<div class="view">
<span class="index">{{ index + 1 }}</span>
<label>{{ item }}</label>
<button class="destroy" @click="remove(index)">刪除</button>
</div>
</li>
</ul>
</section>
<!-- 統(tǒng)計(jì)和清空 -->
<footer class="footer">
<span class="todo-count" v-if="list.length != 0">{{ list.length }}<strong></strong>@nbsp;items left</span>
<button @click="clear" v-show="list.length != 0">Clear</button>
</footer>
</section>
<!-- 底部 -->
<footer class="info">
<p>
<a rel="external nofollow" ><img src="https://www.baidu.com/img/flexible/logo/pc/result.png"/></a>
</p>
</footer>
<!-- 開發(fā)環(huán)境版本 -->
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
var app = new Vue({
el: '#app',
data: {
list: ["糖醋里脊", "紅燒獅子頭", "蒸雞蛋"],
// 初始化輸入值為空
inputValue: ""
},
methods: {
add: function() {
this.list.push(this.inputValue);
},
remove: function(index) {
this.list.splice(index, 1);
},
clear: function() {
this.list = []
}
}
})
</script>
</body>
</html>css樣式表
* {
padding: 0;
margin: 0;
}
#app {
width: 300px;
/* 盒子居中對(duì)齊 */
margin: 5px auto;
box-shadow: 0px 3px 10x 2px rgba(0, 0, 0, 0.1);
}
.title {
font: normal 200 34px '微軟雅黑';
color: rgb(219, 82, 82);
text-align: center;
padding-top: 100px;
padding-bottom: 10px;
}
.new-todo {
width: 100%;
height: 40px;
padding-left: 10px;
color: rgb(88, 88, 88);
box-sizing: border-box;
border: 1px solid rgb(236, 236, 236);
}
.new-todo:focus {
outline: none;
}
.footer {
position: relative;
width: 100%;
height: 40px;
box-sizing: border-box;
border: 1px solid rgb(236, 236, 236);
background-color: white;
}
.footer span {
font-size: 12px;
color: rgb(131, 131, 131);
float: left;
line-height: 40px;
}
.todo-count {
margin-left: 10px;
}
.clear-button {
margin-left: 170px;
}
.todo {
list-style: none;
font-size: 14px;
font-family: '微軟雅黑';
color: rgb(88, 88, 88);
box-sizing: border-box;
width: 100%;
height: 40px;
line-height: 40px;
border: 1px solid rgb(236, 236, 236);
background-color: white;
}
.view {
position: relative;
margin-left: 10px;
}
.view label {
width: 200px;
height: 40px;
position: absolute;
/* 超出的文本隱藏 */
overflow: hidden;
/* 溢出用省略號(hào)表示 */
text-overflow: ellipsis;
/* 溢出不換行 */
white-space: nowrap;
}
.destroy {
position: absolute;
right: 10px;
top: 9px;
font-size: 12px;
font-family: '微軟雅黑';
outline: none;
border: 1px solid rgb(236, 236, 236);
color: rgb(255, 111, 111);
display: none;
}
.view:hover .destroy {
display: block;
}
.footer button {
position: absolute;
right: 10px;
top: 9px;
font-size: 12px;
font-family: '微軟雅黑';
outline: none;
border: 0px;
color: rgb(131, 131, 131);
}
.info {
margin: 5px auto;
width: 300px;
}
.info a {
padding-left: 50px;
}
到此這篇關(guān)于Vue便簽的簡單實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Vue 便簽內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
在瀏覽器console中如何調(diào)用vue內(nèi)部方法
這篇文章主要介紹了在瀏覽器console中如何調(diào)用vue內(nèi)部方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-07-07
解決vue-cli項(xiàng)目開發(fā)運(yùn)行時(shí)內(nèi)存暴漲卡死電腦問題
最近開發(fā)一個(gè)vue項(xiàng)目時(shí)遇到電腦卡死問題,突然間系統(tǒng)就非???,然后卡著卡著就死機(jī)了,鼠標(biāo)也動(dòng)不了了,只能冷啟動(dòng)。這篇文章主要介紹了vue-cli項(xiàng)目開發(fā)運(yùn)行時(shí)內(nèi)存暴漲卡死電腦問題,需要的朋友可以參考下2019-10-10
vite結(jié)合electron構(gòu)建前端桌面應(yīng)用程序
本文主要介紹了vite結(jié)合electron構(gòu)建前端桌面應(yīng)用程序,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05
vue3+element Plus實(shí)現(xiàn)在table中增加一條表單數(shù)據(jù)的示例代碼
這篇文章主要介紹了vue3+element Plus實(shí)現(xiàn)在table中增加一條表單數(shù)據(jù)的操作,本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2024-01-01
Vue3?實(shí)現(xiàn)網(wǎng)頁背景水印功能的示例代碼
這篇文章主要介紹了Vue3?實(shí)現(xiàn)網(wǎng)頁背景水印功能,這里水印的字體大小、顏色和排布參考了企業(yè)微信的背景水印,使得看起來不那么突兀,需要的朋友可以參考下2022-08-08
Vue openLayers實(shí)現(xiàn)圖層數(shù)據(jù)切換與加載流程詳解
OpenLayers是一個(gè)用于開發(fā)WebGIS客戶端的JavaScript包,最初基于BSD許可發(fā)行。OpenLayers是一個(gè)開源的項(xiàng)目,其設(shè)計(jì)之意是為互聯(lián)網(wǎng)客戶端提供強(qiáng)大的地圖展示功能,包括地圖數(shù)據(jù)顯示與相關(guān)操作,并具有靈活的擴(kuò)展機(jī)制2022-09-09
詳解vue-cli項(xiàng)目在IE瀏覽器打開報(bào)錯(cuò)解決方法
這篇文章主要介紹了詳解vue-cli項(xiàng)目在IE瀏覽器打開報(bào)錯(cuò)解決方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
Vue項(xiàng)目使用electron打包桌面應(yīng)用方式
本文詳細(xì)介紹了如何使用Vue3和Electron創(chuàng)建一個(gè)桌面應(yīng)用程序,并提供了一個(gè)完整的步驟指南,包括項(xiàng)目初始化、配置、安裝依賴、主進(jìn)程和渲染進(jìn)程的設(shè)置、打包配置以及解決常見問題的方法2025-12-12

