Weex开发中的应用小笔记
内容:
获取输入或其他操作使得值一直改变并在一段不改变的时间后执行下一步操作(输入搜索关键字并执行搜索)
https://vuejs.org/v2/guide/computed.html?spm=a2c7j.-zh-docs-components-recycle-list.0.0.9f1a3dcb7cO5F4#Watchers
var watchExampleVM = new Vue({
el: '#watch-example',
data: {
question: '',
answer: 'I cannot give you an answer until you ask a question!'
},
watch: {
// whenever question changes, this function will run
question: function (newQuestion, oldQuestion) {
this.answer = 'Waiting for you to stop typing...'
this.debouncedGetAnswer()
}
},
created: function () {
// _.debounce is a function provided by lodash to limit how
// often a particularly expensive operation can be run.
// In this case, we want to limit how often we access
// yesno.wtf/api, waiting until the user has completely
// finished typing before making the ajax request. To learn
// more about the _.debounce function (and its cousin
// _.throttle), visit: https://lodash.com/docs#debounce
this.debouncedGetAnswer = _.debounce(this.getAnswer, 500)
},
methods: {
getAnswer: function () {
if (this.question.indexOf('?') === -1) {
this.answer = 'Questions usually contain a question mark. ;-)'
return
}
this.answer = 'Thinking...'
var vm = this
axios.get('https://yesno.wtf/api')
.then(function (response) {
vm.answer = _.capitalize(response.data.answer)
})
.catch(function (error) {
vm.answer = 'Error! Could not reach the API. ' + error
})
}
}
})
</script>
js获取当前页面的地址(此处为完整路径)
this.$getConfig().bundleUrl
复杂表达式不应该出现在数据绑定中,可以通过定义计算computed属性来实现方便管理维护
<div id="example">
<p>Original message: "{{ message }}"</p>
<p>Computed reversed message: "{{ reversedMessage }}"</p>
</div>
var vm = new Vue({
el: '#example',
data: {
message: 'Hello'
},
computed: {
// a computed getter
reversedMessage: function () {
// `this` points to the vm instance
return this.message.split('').reverse().join('')
}
}
})
值绑定的操作只发生一次
通过使用 v-once 指令,你也能执行一次性地插值,当数据改变时,插值处的内容不会更新。但请留心这会影响到该节点上所有的数据绑定: <span v-once>This will never change: {{ msg }}</span>
将输入控件的值通过v-model和属性值进行绑定
http://doc.vue-js.com/v2/guide/
<div id="app">
<p>{{ message }}</p>
<input v-model="message">
</div>
在莫个VUE文件中引用自定义控件的方法
import { WxcTabPage, WxcPanItem, Utils, BindEnv,WxcPopup } from 'weex-ui';
import ProblemsItem from "./problems-item";
通过比较可以容易发现前后写法之间的关系(没有设置component属性值)alt+点击可以进入查看莫个实现的写法
自定义控件增加一个事件(带上参数)
this.$emit('sendRequestForQuestion', this.problem);
设置属性时处理这个事件
<problems-item @sendRequestForQuestion = sendRequestForQuestion :problem=p />
上面同时设定了属性problem这个在空间中的属性定义为
export default {
components: { WxcPanItem },
props: {
problem: {
type: Object,
default: {}
},
},
data: () => ({ }),
methods: {
handleAskQuestion() {
// this.$notice.toast('handleAskQuestion:')
this.$emit('sendRequestForQuestion', this.problem);
}
}
}
data属性一定要写对位置,否者比如遇到BOOL类型的属性,可能出现页面不刷新或者只刷新第一次的问题
wxc-popup显示和点击空白会出现动画效果,点击上面的控件隐藏需要通过hide方法
popupBottomHide () {
this.$refs.popupContent.hide()
// this.$notice.toast('popupOverlayBottomClick:')
},
flex-grow元素占据父元素剩余空间的比例
list不存在自定义重用标识,每次都是重新移除/添加控件到Cell上面,而且不支持Group类型的list
http://dotwe.org/vue/035a0ee995d71c510161cba6e123d818
选项卡左右滑动切换类型页面
https://alibaba.github.io/weex-ui/#/cn/packages/wxc-tab-page/
左右上下弹出控件
https://alibaba.github.io/weex-ui/#/cn/packages/wxc-popup/
weex动画使用animation.transition函数
http://dotwe.org/vue/3e8660d7182f24901f122a0855c09370
https://www.jianshu.com/p/ab3e9f06f106
<script>
const animation = weex.requireModule('animation')
const modal = weex.requireModule('modal') export default {
data: function () {
return {
current_rotate: 0
}
},
mounted () {
let that = this
let el = this.$refs.test
setInterval(function () {
that.rotate(el)
}, 600)
},
methods: {
rotate (el) {
let self = this;
this.current_rotate+=360;
animation.transition(el, {
styles: {
color: '#FF0000',
transform: 'rotate(' + self.current_rotate + 'deg)',
transformOrigin: 'center center'
},
duration: 600, //ms
timingFunction: 'ease',
delay: 0 //ms
},function () { })
}
}
}
</script>
Weex开发中的应用小笔记的更多相关文章
- Android开发中实现桌面小部件
详细信息请参考原文:Android开发中实现桌面小部件 在Android开发中,有时候我们的App设计的功能比较多的时候,需要根据需要更简洁的为用户提供清晰已用的某些功能的时候,用桌面小部件就是一个很 ...
- JAVA开发中遇到的小白点
这里主要是自己个人开发中遇到的一些小问题,自己攒起来,来弥补自己薄弱的JAVA基础,大神不要见笑 1. DateFormat格式化的HH和hh区别: public static boolean com ...
- 在Android 开发中使用 SQLite 数据库笔记
SQLite 介绍 SQLite 一个非常流行的嵌入式数据库,它支持 SQL 语言,并且只利用很少的内存就有很好的性能.此外它还是开源的,任何人都可以使用它.许多开源项目((Mozilla, PH ...
- RS开发中的一些小技巧[不定期更新]
从9月份一直忙到了现在,项目整体的改版工作也完成了十有八九了,有些事情只有你自己真正的做了,你才能明白:哦,原来还可以这个样子,这样做真的好了很多呢,接下来我就分享一些最近遇到的RS开发的一些小技巧, ...
- APP落地页开发中的一些小经验~
在开发日常落地页的时候,每当碰到一些很酷炫的宣传图用css实现很复杂且耗时的时候,一般采取切图然后将其放在页面中,在这个过程中发现<img/>标签中图片下方会有一行小空白,影响了与后一部分 ...
- Java开发中经典的小实例-(二分法)
public int binarySearch(int[] data,int aim){//以int数组为例,aim为需要查找的数 int start = 0; int end = data.leng ...
- iOS开发中的零碎知识点笔记 韩俊强的博客
每日更新关注:http://weibo.com/hanjunqiang 新浪微博 1.关联 objc_setAssociatedObject关联是指把两个对象相互关联起来,使得其中的一个对象作为另外 ...
- 日常开发中的shell小技巧
工具推荐 命令行中很方便的代码统计工具---cloc 强大的分屏工具---tmux 最舒服的markdown书写工具---typora markdown图床推荐--七牛云 模拟生成熵(避免暴力手搓键盘 ...
- Android开发中遇到的小问题 一
1)想要ListView活着Girdview左右留些空隙,但Scrollbar要在屏幕最右边 在xml中加入 android:paddingLeft="8dp" android:p ...
随机推荐
- Angular7_获取异步方法里面的数据
1.回调函数 getName() { return '张三'; } getAsyncName() { setTimeout(() => { return 'async_张三'; }, ); } ...
- pythonのsqlalchemy多对多关系
现在来设计一个能描述“图书”与“作者”的关系的表结构,需求是 一本书可以有好几个作者一起出版 一个作者可以写好几本书 #!/usr/bin/env python from sqlalchemy imp ...
- TCP/IP(五)传输层之细说TCP的三次握手和四次挥手
前言 这一篇我将介绍的是大家面试经常被会问到的,三次握手四次挥手的过程.以前我听到这个是什么意思呀?听的我一脸蒙逼,但是学习之后就原来就那么回事! 一.运输层概述 1.1.运输层简介 这一层的功能也挺 ...
- centos7端口永久开放方法
/sbin/iptables -I INPUT -p tcp --dport -j ACCEPT /sbin/iptables -I INPUT -p tcp --dport -j ACCEPT /s ...
- Java面试题复习笔记(数据库)
1.数据库分类? 关系型数据库和非关系型. 常用关系型:Myspl.Oracle.SQLServer 非关系型:Redis.Hadoop.Memcache.Mogobd 2.关系数据库三范式? 范式就 ...
- yum install 报错[Errno 14] curl#37 - Couldn't open file /mnt/repodata/repomd.xml
最近在玩centos7,之前装系统没太注意yum这个东东,今天用别人装好的系统想用yum install 一个东西,结果报各种错,所以就是: 1.然后按照网上的一些修改,先是执行: yum cleam ...
- 【Java】JDK/JVM相关工具
1.JDK自带工具 1)常见的用法参见:https://cloud.tencent.com/developer/article/1379487 2)HSDB,即Hotspot debugger,位置在 ...
- 倒影问题(reflect:below)
这个例子灵感来源于实现一个登录框下方的倒影: .box { width: 300px; height: 200px; border: 1px solid #1f637b; -webkit-box-re ...
- 快速启动FTP下载服务器
nohup python -m SimpleHTTPServer 8000 > myout.file 2>&1 &
- get方法与post方法的区别与js获取url参数的方式
1.get方法与post方法的区别: 区别一:get重点在从服务器上获取资源,post重点在向服务器发送数据:区别二:get传输数据是通过URL请求,以field(字段)= value的形式,置于UR ...