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 ...
随机推荐
- JAVA进阶9
间歇性混吃等死,持续性踌躇满志系列-------------第9天 1.使用throw语句抛出异常 在通常情况下,程序发生错误时系统会自动抛出异常,而有时希望程序自动抛出异常,可以使用throw语句来 ...
- 在c:forEach与s:iterator里面使用if标签判断当前位置是否为2的倍数
在c:forEach与s:iterator里面使用if标签判断当前位置是否为2的倍数 c:forEach: <c:forEach var="workflow" items=& ...
- IDEA 在同一目录创建多个项目
以往的Eclipse.NetBeans等开发工具不同,IDEA的Project相当与Eclipse的Workspace,而Module相当于Project. 下边就给出Eclipse与IDEA的概念的 ...
- html(jQuery)替换字符串(全部替换)
var str= "a<br/>b<br/>c<br/>"; var Newstr = str.replace("<br/&g ...
- C++设计模式——命令模式
什么是命令模式? 在GOF的<设计模式:可复用面向对象软件的基础>一书中对命令模式是这样说的:将一个请求封装为一个对象,从而使你可用不同的请求对客户进行参数化:对请求排队或记录请求日志,以 ...
- 002_soa_zk处理经验总结
一. 遇到这种情况直接把当前目录下的acceptedEpoch和currentEpoch挪走,重启publisher即可. cat /data/zookeeper/data/version-2/acc ...
- (原创)cocos2dx-lua TableView官方demo分析
本来是想看看网上的教程文章,结果看了好几篇,复制代码各种报错,有很多不存在的类和变量,根本用不了. 所以干脆自己去看官方demo,经过自己分析测试,已经大概会用了,顺便记录一下. 以下是代码,复制粘贴 ...
- 在普通js文件里引入vue实例的方法
首先是我是写了一个 Loading 插件然后 是挂在打vue.prototype 原型上的. 在main.js中use使用了这个插件. 至此vue原型是就被我挂上 $loadding方法了. 然后我想 ...
- 【Bootstrap】 typeahead自动补全
typeahead 这篇文章记录了我在使用typeahead的一些问题,不是很全,但是基本够用. Bootstrap提供typeahead组件来完成自动补全功能. 两种用法: 直接给标签添加属性 &l ...
- APP,H5测试要点
APP测试重点 一,运行测试 运行过程中,是否有加载提示: 运行速度是否流畅: 各个模块之间的切换是否正常: 二,更新测试:打开旧版app时,是否有更新提示,且在不同的手机版本上都能更新成功:打开新版 ...