首页 > 其他分享 >鸿蒙JS UI的Hml语法技巧,hml中实现多列表的方式

鸿蒙JS UI的Hml语法技巧,hml中实现多列表的方式

时间:2023-10-03 21:34:13浏览次数:36  
标签:src description CommonConstants imageCards JS Hml hook UI common

由于没有web基础,不懂html和js。需要从基础学起。

刚刚学到在hml中实现多列表的方式,记录一下

<div class="container">
    <div class="card-container" for="item in imageCards" show="{{ item.isShow }}">
        <div class="text-container">
            <text class="text-operation">{{ contentTitle }}</text>
            <text class="text-description">{{ item.description }}</text>
        </div>
        <image class="{{ item.classType }}" src="{{ item.src }}" onclick="changeHookState({{ item.eventType }})"/>
    </div>
</div>

对应的JS

import CommonConstants from '../../common/constants/commonConstants';

export default {
  data: {
    contentTitle: '',
    hook: true,
    imageCards: [
      {
        src: '/common/images/ic_heart_rate.png',
        classType: 'img-normal',
        eventType: 'touch',
        description: '',
        isShow: true,
      },
      {
        src: '/common/images/ic_hook.png',
        eventType: 'click',
        classType: 'img-normal',
        description: '',
        isShow: false,
      },
    ],
    durationTimeArray: [CommonConstants.DURATION_TIME, CommonConstants.DURATION_TIME],
    arrow: CommonConstants.ARROW_FRAMES,
    collapse: CommonConstants.COLLAPSE_FRAMES
  },
  onInit() {
    this.contentTitle = this.$t('strings.content_title');
    this.imageCards[0].description = this.$t('strings.normal_description');
    this.imageCards[1].description = this.$t('strings.select_description');
  },
  changeHookState(eventType) {
    if (eventType === 'touch') {
      return;
    }
    if (this.hook) {
      this.imageCards[1].src = '/common/images/ic_fork.png';
      this.hook = false;
    } else {
      this.imageCards[1].src = '/common/images/ic_hook.png';
      this.hook = true;
    }
  },
} 

 

标签:src,description,CommonConstants,imageCards,JS,Hml,hook,UI,common
From: https://www.cnblogs.com/LiuSiyuan/p/17741674.html

相关文章

  • Module build failed (from ./node_modules/css-loader/dist/cjs.js): CssSyntaxError
    问题描述在webpack的时候报错ERRORin./packages/theme-chalk/mixins/mixins.scss(./node_modules/css-loader/dist/cjs.js!./packages/theme-chalk/mixins/mixins.scss)Modulebuildfailed(from./node_modules/css-loader/dist/cjs.js):CssSyntaxError(14:8)......
  • Angular 应用构建完成后 vendor.js 文件的使用场合
    vendor.js文件的来源、作用和使用场合vendor.js文件是Angular应用中的一个重要文件,它承担了许多关键任务,包括管理应用的依赖关系、提供框架核心功能以及优化构建。本文将详细介绍vendor.js的来源、作用和使用场合,并通过示例来阐述。来源vendor.js文件的来源可以追溯到Angular应......
  • Go - Creating JSON Data Streams from Structs
    Problem: YouwanttocreatestreamingJSONdatafromstructs.Solution: CreateanencoderusingNewEncoderintheencoding/jsonpackage,passingitanio.Writer.ThencallEncodeontheencodertoencodestructsdatatoastream. Theio.Writerinterfa......
  • Go - Creating JSON Data Byte Arrays from Structs
    Problem: YouwanttocreateJSONdatafromastruct.Solution: Createthestructsthenusethejson.Marshalorjson.MarshalIndenttomarshalthedataintoaJSONsliceofbytes. funcmain(){person:=struct{}data,err:=......
  • Go - Parsing JSON Data Streams Into Structs
    Problem: YouwanttoparseJSONdatafromastream.Solution: CreatestructstocontaintheJSONdata.CreateadecoderusingNewDecoderintheencoding/jsonpackage,thencallDecodeonthedecodertodecodedataintothestructs. InthisfirstJSONf......
  • 深航电企业评价评级系统可视化(HTML,CSS,JS)
    一.项目背景深航电企业评价评级系统EERS是一款企业绩效评价平台,旨在为企业提供科学、全面、精准的绩效评价服务,帮助企业发现问题、改进管理,提高整体绩效。EERS评级系统借助大数据、云计算、人工智能等现代技术手段,将企业绩效数据进行多维度、系统化、动态化分析,为企业提供可视化......
  • nvm 安装与使用(实现Nodejs版本切换,及找不到npm的问题)
    https://blog.csdn.net/sxk1101/article/details/129208573除文章操作,别忘记把 nvm安装与使用(实现Nodejs版本切换,及找不到npm的问题)......
  • Arduino IDE1.8.3安装
              ......
  • 无涯教程-OC - UI元素
    UI元素是我们可以在应用程序中看到的视觉元素。这些元素中的一些响应用户交互(如按钮,文本字段),而其他信息则有意义(如图像,标签)。UI元素列表UI特定元素及其相关功能在下面说明-产品编号。UI特定元素1TextFields这是一个UI元素,使应用程序可以获取用户输入。2Input......
  • 运维 | 如何使用 nvm 安装和管理 nodeJS 版本
    运维|如何使用nvm安装和管理nodeJS版本简介NVM是什么nvm(NodeVersionManager)是NodeJS版本管理器,可对不同的node版本快速进行切换。为什么要用NVM基于node的工具和项目越来越多,但是每个项目使用的node版本可能不一致,就会出现一些奇怪的问题。比如:自己电脑......