当前位置:网站首页>【无标题】记事本内容编写区
【无标题】记事本内容编写区
2022-04-22 05:45:00 【礼礼。】

HTML
<div>
<div>
//标题
<div>
<input
type="text"
placeholder="标题..."
value="{
{title}}" //在data处定义title变量
maxlength="20" //最多输入20 个字
onchange="getTitle"
/>
</div>
//内容
<div>
<textarea
placeholder="输入内容"
value="{
{content}}" //在data处定义content变量
onchange="getContent"
></textarea>
</div>
//标签
<text>添加个标签吧~</text>
<div>
<text
class="{
{label == '普通'?'common':''}}" //在data处定义label变量,并写好默认值
onclick="changeLabel('普通')"
>普通</text>
<text
class="{
{label == '重要'?'important':''}}"
onclick="changeLabel('重要')"
>重要</text>
<text
class="{
{label == '待办'?' to-do':''}}"
onclick="changeLabel('待办')"
>待办</text>
</div>
</div>
//完成按钮 opacity:颜色的透明度 当按钮canAdd可点击时透明度为1 否则为0.3 即30%
<div>
<text onclick="addMemo" style="opacity: {
{canAdd ? '1' : '0.3'}};" >完成</text>
</div>
</div>
JS
//引入文件
import {
getMemoList, setMemoList } from '../../helper/data.js'
import router from '@system.router'
.......
data() {
return {
index: '',
title: '',
content: '',
label: '普通'
}
},
.......
// 标题 οnchange="getTitle"
getTitle(e) {
this.title = e.value
},
// 内容 οnchange="getContent"
getContent(e) {
this.content = e.value
},
//标签
changeLabel(label) {
this.label = label
},
// 完成 οnclick="addMemo"
computed: {
canAdd() {
if (this.title && this.content) {
return true //检测到有内容和标题时 “完成”按钮可点击 true 否则false
} else {
return false
}
}
},
.........
//异步操作
async addMemo() {
if (this.title && this.content) {
const memoAdd= {
title: this.title,
content: this.content,
label: this.label,
timestamp: +new Date(),
is_top:false,
}
const memoList = await getMemoList()
if (this.index !== '') {
memoList[this.index] = memoAdd
} else {
memoList.push(memoAdd)
}
setMemoList(memoList)
router.back()
}
},
版权声明
本文为[礼礼。]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_45736311/article/details/124007014
边栏推荐
- jeecgboot-online錶單開發-控件配置
- Opencv code
- Part 75 leetcode exercise (8) 8 String to integer
- Binary search and its classical applications (left boundary, right boundary, etc.)
- Code color difference of QT learning
- qt打包程序打包之跨平台
- Compiling OpenSSL of arm64 on M1 chip
- Developing Postgres custom function with C language
- 关于常量指针、指针常量的使用--练习题(记录)
- opencv代码
猜你喜欢

Access problems after setting up the local server

CAN 数据帧,远程帧,错误帧,以及出错重连

Chapter 88 leetcode sword refers to offer dynamic programming (V) maximum value of gifts

Universal timer

STM32 learning note 1 - the simplest GPIO

通过js创建单元格(while循环)

STM32 learning note 5 - Calculation of relative position of RGB screen

qt打包程序打包之跨平台

Analysis of Modbus Protocol in TCP communication

Geojson file ShapeFile file batch conversion gadget
随机推荐
自动获取指定路径文件夹,删除文件夹及子文件
opencv图像增强
QT add PRI compile run: error: fatal error: no input files problem solving
Experience of constructing H-bridge with MOS tube
membarrier(个人学习理解)
STL学习笔记0x0001(容器分类)
单、多通道图像反差处理
Halcon and opencv or Halcon configuration modify the inheritance value of the included directory and Library Directory
Opencv code
Modbus Protocol
Single and multi-channel image contrast processing
c#委托、线程、定时器学习感悟
Markdown 语法支持测试
STL函数库
LeetCode: 322. 零钱兑换(动态规划,递归,备忘录递归以及回溯)
常见面试问题 - 1(非技术)
常见面试问题 - 3(操作系统)
qt打包程序打包之跨平台
Geojson file and ShapeFile file single conversion gadget
Chapter 86 leetcode refers to offer dynamic programming (III) maximum profit of stock