读琼瑶新闻有感

琼瑶的电视剧看过,还珠格格,情深深雨濛濛,

很多人演过

特别是赵薇

还因此得利,

哦,还有那个什么 紫薇  林心如

武侠小说的作者 也死了

种水稻的 袁农平 也是

还有之前疫情的医生  赵文亮医生

还有那些 领导人

其实,死了,无感,因为对社会没有什么贡献,

以后每个人都会死,死了,也是无感的

所以,生活啊, 只有自己的感受是最重要的,

修改下面代码// pages/TaskListPage.ets import { TaskItem } from "../View/TaskItem"; import { TaskModel } from "../Model/TaskModel"; import { router } from '@kit.ArkUI'; import CreateTaskModel from "../Model/TaskModel"; @Entry @Component struct TaskListPage { @StorageLink('novelList') taskList: Array<TaskModel> = []; private listScroller: Scroller = new Scroller(); aboutToAppear() { this.taskList = CreateTaskModel.getNovelList(); } build() { Stack({alignContent: Alignment.BottomEnd}) { Column() { Text("小说列表").fontSize(28).margin(16) List({scroller: this.listScroller}) { ForEach(this.taskList, (item: TaskModel) => { ListItem() { TaskItem({task: item}) } }) }.layoutWeight(1) }.width("100%") Button("添加小说") .onClick(() => router.pushUrl({url: "pages/AddTaskPage"})) .margin(20) } .width("100%") .height("100%") .backgroundColor(0xf1f3f5) } }和// ets/view/TaskItem.ets import { TaskModel } from "../Model/TaskModel"; @Component export struct TaskItem { @Prop task: TaskModel; build() { Row() { Column() { Text(this.task.novelTitle).fontSize(18) Text(`作者: ${this.task.novelAuthor}`).fontSize(14) }.width("80%") } .width("100%") .padding(12) .backgroundColor(Color.White) .borderRadius(8) .margin({bottom: 8}) } }和// ets/viewmodel/TaskModel.ets import { AppStorageV2 } from '@kit.ArkUI'; // 使用正确的API名称 export class TaskModel { novelId: string = ""; novelTitle: string = ""; novelAuthor: string = ""; novelContent: string = ""; createDate: string = ""; taskStatus: string = ""; constructor(novelId: string, novelTitle: string, novelAuthor: string, novelContent: string, createDate: string, taskStatus: string) { this.novelId = novelId; this.novelTitle = novelTitle; this.novelAuthor = novelAuthor; this.novelContent = novelContent; this.createDate = createDate; this.taskStatus = taskStatus; } } export class CreateTaskModel { private static readonly STORAGE_KEY = 'novelList'; static initStorage() { if (!AppStorageV2.Has(CreateTaskModel.STORAGE_KEY)) { AppStorageV2.SetOrCreate( CreateTaskModel.STORAGE_KEY, CreateTaskModel.getTaskListData() ); } } static getNovelList(): Array<TaskModel> { return AppStorageV2.Get(CreateTaskModel.STORAGE_KEY) || []; } static addNovel(novel: TaskModel): void { const currentList = CreateTaskModel.getNovelList(); AppStorageV2.SetOrCreate( CreateTaskModel.STORAGE_KEY, [...currentList, novel] ); } private static getTaskListData(): Array<TaskModel> { const authors = ["金庸", "古龙", "琼瑶"]; const titles = ["天龙八部", "射雕英雄传", "神雕侠侣"]; return Array.from({length: 3}, (_, i) => new TaskModel( i.toString(), titles[i], authors[i], "小说内容示例", new Date().toLocaleDateString(), "undone" )); } } // 初始化存储(使用类名调用静态方法) CreateTaskModel.initStorage();和// pages/AddTaskPage.ets import { TaskModel } from "../Model/TaskModel"; import { router } from '@kit.ArkUI'; import CreateTaskModel from "../Model/TaskModel"; @Entry @Component struct AddTaskPage { @State novelTitle: string = ""; @State novelAuthor: string = ""; @State novelContent: string = ""; build() { Column() { Text("新建小说").fontSize(26).margin({top: 16, bottom: 16}) Column({space: 20}) { // 小说标题 TextInput({placeholder: "小说标题", text: $$this.novelTitle}) .width("100%").height(40) // 小说作者 TextInput({placeholder: "小说作者", text: $$this.novelAuthor}) .width("100%").height(40) // 小说内容 TextInput({placeholder: "小说内容", text: $$this.novelContent}) .width("100%").height(150) Button("创建小说") .onClick(() => { if (this.novelTitle && this.novelAuthor) { const novel = new TaskModel( Date.now().toString(), this.novelTitle, this.novelAuthor, this.novelContent, new Date().toLocaleDateString(), "undone" ); CreateTaskModel.addNovel(novel); router.back(); } }) }.width("100%").padding(10) }.width("100%").height("100%").backgroundColor(0xf1f3f5) } }实现在Addtask的界面添加小说标题,作者,内容;在TaskList展示添加的小说标题和作者;改正四段代码,输出完整修改后的代码;Model不要导入
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值