按钮

react-hook简单使用

a 夏天 提交于 2020-01-02 15:47:28
一、函数式组件创建 function HelloComponent(props, /* context */) { return <div>Hello {props.name}</div> } ReactDOM.render(<HelloComponent name="Sebastian" />,document.getElementById("mountNode")) 这里我们可以知道该组件中并没有自己的状态,但实际开发中往往需要内部的状态实现一系列的交互和展示功能.所以我们用class创建组件更多一点.但是,纯函数的组件式创建更符合react的思想,于是为了解决状态问题,完善的函数式组件创建模式出现:react-hook 首先需要明确的一点是,hook中没有this指针,所以相关的api都需要改变才. 二、常用HOOK API 结合class式组件进行对比 1.组件申明 class: export default class Text extends React.Component {} Hook const Text = {} export default Text 2.state (1)初始化 class constructor(props) { super(props); this.state = { name: '小明', age:1 }; } Hook const

[Android 問題] How to Add a Button in ListView, and Make the Event of onClick and onItemClick Coexist?

久未见 提交于 2020-01-02 07:53:45
If you add a Button on the view of each item in ListView , the touch event is catched and reacted by the button instead of the ListView even outside the area of the Button . The item can not be selected and switched. It's a simplest solution that you can set the attribute android:focusable to be false to fix it as showed below: <Button android:id="@+id/contact_list_item_hd_button" android:layout_width="30px" android:layout_height="30px" android:layout_gravity="center_vertical" android:layout_marginRight="10px" android:background="@drawable/contactlist_hd_button" android:textSize="8sp" android

QT学习之路---信号槽

坚强是说给别人听的谎言 提交于 2020-01-02 05:36:55
#include<QApplication> #include<QPushButton> int main(int argc,char *argv[]) { QApplication a(argc,argv); QPushButton *button = new QPushButton("Quit"); QObject::connect(button,SIGNAL(clicked()),&a,SLOT(quit())); button->show(); return a.exec(); } 其中: QObject::connect(button,SIGNAL(clicked()),&a,SLOT(quit())); Qobject是所有类的根,Qt使用这个Qobject实现了一个单根继承的c++。它里面有一个connect静态函数,用于连接信号槽 具体来说:QApplication的实例a说,如果button发出了clicked信号,你就去执行我的quit函数。所以,当我们点击button的时候,a的quit函数被调用,程序退出。    注意:Qt中头文件和类名是一致的。也就是说,如果你要使用某个类的话,它的类名就是它的头文件名。 #include<QLabel> QLabel *label = new QLabel("Hello,world"); 创建一个QLabel对象

vue.js 组件二

岁酱吖の 提交于 2020-01-02 04:37:41
Vuejs——组件——props数据传递 标签: vuejs props 2016-09-04 23:16 3173人阅读 评论 (0) 收藏 举报 分类: Vue(19) 版权声明:出处http://blog.csdn.net/qq20004604 目录 (?) [+] 本篇资料来于官方文档: http://cn.vuejs.org/guide/components.html#Props 本文是在官方文档的基础上,更加细致的说明,代码更多更全。 简单来说,更适合新手阅读 (二十六)props数据传递 ①组件实例的作用域: 是孤立的,简单的来说,组件和组件之间,即使有同名属性,值也不共享。 [html] view plain copy < div id= "app" > < add > </ add > < del > </ del > </ div > < script > var vm = new Vue({ el: '#app', components: { "add": { template: " < button >btn:{{btn}} </ button >", data: function () { return {btn: "123"}; } }, del: { template: " < button >btn:{{btn}} </ button >",

Vue 及双向数据绑定 Vue事件 以及Vue中的ref获取dom节点

拥有回忆 提交于 2020-01-02 04:13:18
<template> <div id="app"> <h2>{{msg}}</h2> <input type="text" v-model='msg' /> <button v-on:click="getMsg()">获取表单里面的数据get</button> <button v-on:click="setMsg()">设置表单的数据set</button> <br> <br> <hr> <br> <br> <input type="text" ref="userinfo" /> <br> <br> <div ref="box">我是一个box</div> <br> <br> <button v-on:click="getInputValue()">获取第二个表单里面的数据</button> </div> </template> <script> /* 双向数据绑定 MVVM vue就是一个MVVM的框架。 M model V view MVVM: model改变会影响视图view,view视图改变反过来影响model 双向数据绑定必须在表单里面使用。 */ export default { data () { /*业务逻辑里面定义的数据*/ return { msg: '你好vue' } },methods:{ /*放方法的地方*/ getMsg(){ // alert(

WPF网格绑定按钮并通过DataContext控制按钮是否可用

杀马特。学长 韩版系。学妹 提交于 2020-01-02 02:57:48
1、资源字典 <ResourceDictionary> <FrameworkElement x:Key="ProxyElement" DataContext="{Binding}"/> 2、内容 </GroupBox> <ContentControl Visibility="Collapsed" Content="{StaticResource ProxyElement}"/> 3、绑定方法 IsEnabled="{Binding DataContext.BtnIsEnabled,Source={StaticResource ProxyElement}}" 来源: https://www.cnblogs.com/huzige/p/11088992.html

Android Button的基本使用

核能气质少年 提交于 2020-01-01 23:38:56
title: Android Button的基本使用 tags: Button,按钮 --- Button介绍: Button(按钮)继承自TextView,在Android开发中,Button是常用的控件,用起来也很简单,你可以在界面xml描述文档中定义,也可以在程序中创建后加入到界面中,其效果都是一样的。不过最好是在xml文档中定义,因为一旦界面要改变是话,直接修改一下xml就行了,不用修改Java程序,并且在xml中定义层次分明,一目了然。 Button 支持的 XML 属性及相关方法 XML 属性 相关方法 说明 android:clickable setClickable(boolean clickable) 设置是否允许点击。 clickable=true:允许点击 clickable=false:禁止点击 android:background setBackgroundResource(int resid) 通过资源文件设置背景色。 resid:资源xml文件ID 按钮默认背景为android.R.drawable.btn_default android:text setText(CharSequence text) 设置文字 android:textColor setTextColor(int color) 设置文字颜色 android:onClick

layer弹出层移动端组件

自作多情 提交于 2020-01-01 14:21:53
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no"> <title>layer移动端弹窗</title> <style> button{ width:6rem; height:3rem; line-height: 3rem; } </style> <!-- http://layer.layui.com/mobile/ layer mobile-v2.0 --> </head> <body> <button id="loading">loading</button> <button id="toast">toast</button> <script src="layer.js"></script> <script> var loadingdom = document.getElementById("loading"); loadingdom.onclick = function(){ //loading带文字 layer.open({ type: 2 ,content: '加载中' /* ,time:"3"*/ }); }; /

web前端入门到实战:jQuery中的事件、动画、表单应用

半世苍凉 提交于 2020-01-01 10:20:47
什么是事件? 页面对不同访问者的响应叫做事件。事件处理程序指的是当 HTML 中发生某些事件时所调用的方法。在事件中经常使用术语 " 触发 " (或 " 激发 " )常用click()方法触发 DOM的加载 $(document).ready() 方法与 window.onload () 方法的区别: 事件绑定 使用bind()方法为每个匹配元素的特定事件绑定事件处理函数。bind() 方法的调用格式: bind(type,[data], fn ) • type: 含有一个或多个事件类型的字符串,由空格分隔多个事件。比如 "click" 或 "submit" ,还可以是自定义事件名。 • data: 作为 event.data 属性值传递给事件对象的额外数据对象 • fn : 绑定到每个匹配元素的事件上面的处理函数 实例: //事件绑定 $("#btn1").bind("click",function(){ alert("点我触发bind函数"); }) <button id="btn1">点我触发bind函数</button> 使用 jQuery 的 is()方法判断元素是否可见,使用is()方法: alert($("button").parent().is("body")); /* * $("#b1").is(":visible") 判断id为d1的元素是否可见 *

2020年你还没用BEM?

☆樱花仙子☆ 提交于 2020-01-01 07:26:32
当你看到一个class的时候,你想得到什么? 这个class用在什么地方,作用是什么? 是否在其他地方也有使用该class,修改会不会引起其他地方的样式问题? class 是否在js中被使用? 等等等等 此时,你最想一眼看到这个class就解决以上所有的问题,那么就引入了今天的主题 BEM—css命名规范 当你第一次看到css包含着-、__、–、- 这些乱七八糟的字符时,脸上笑嘻嘻,心里***。当我第一次看到这样的css的时候,我也没法冷静的看完,但是当你在工作中使用这些css命名规范的时候,不知不觉你会发现,这些符号带来的优势,要远比多写几个字符要多的多 BEM介绍 BEM,它代表 block , element 和 modifier ,blcok可以理解成独立的块,在页面中该块的移动并不会影响到内部样式(和组件的概念类似,独立的一块),element就是块下面的元素,和块有着藕断丝连的关系,modifier是表示样式大小等 BEM是一种非常有用,功能强大且简单的命名约定,它使您的前端代码更易于阅读和理解,易于使用,易于扩展,更健壮和明确,并且更加严格。 BEM方法可确保参与网站开发的每个人都使用单一代码库,并且使用相同的语言。使用正确的命名将使您为网站设计的更改做好准备。 BEM可以用于js中,在JavaScript中并进行模板化,但是需要特殊的框架(暂不深入探索)