当前位置:K88软件开发文章中心编程语言JavaScriptJS01 → 文章内容

Framework7初步尝试(一):不支持siblings()

减小字体 增大字体 作者:佚名  来源:网上搜集  发布时间:2019-1-4 8:50:55

-->

Framework7 doesn’t use any third party library, even for DOM manipulation. It has its own custom DOM7 – DOM library that utilizes most edge and high-performance methods for DOM manipulation. You don’t need to learn something new, its usage is very simple because it has the same syntax as well known jQuery library with support of the most popular and widely used methods and jQuery-like chaining.

官方说Framework7不需要任何第三方library,因为自带的Dom7已经集成了常用的Dom操作,使用方法和jquery/Zepto是一样的。(好吧,算是jquery的精简版,稍后就知道多坑了!)

To start use it there is a?

1
Dom7

?global window function, but we recommend to assign it to some local variable with more handy name, like?

1
$$

官方提供有一个 Dom7 的全局变量,为了方便使用,我们用 $$ 存储到局部变量中。。

//Export DOM7 to local variable to make it easy accessable

var $$ = Dom7;

然后呢就列举了一大堆 Dom7的方法,使用和juqery/zepto是一模一样的。然后踩坑开始了。

? <script>

$$(‘.toolbar-inner a’).on(‘click’,function(){

$$(this).addClass(‘active’);

// $$(this).siblings().removeClass(‘active’); ? 注意这里并不支持 siblings()方法

$$(this).nextAll().removeClass(‘active’);

$$(this).prevAll().removeClass(‘active’);

});

</script>


既然不支持那就只能前后查找了。

$$(this).nextAll().removeClass(‘active’);

$$(this).prevAll().removeClass(‘active’);

最后做了一个小 demo:http://www.k88.net/demo/sosuo/baidu.html

这里说下phonegap的打包,说下在线打包,这个功能和hbuilder有点类似,只不过hbuilder是集成在ide内了,phonegap是web形式,支持ios,安卓,wp

https://build.phonegap.com/apps/

这里就不多把玩了。下面给出的是web形式


Framework7初步尝试(一):不支持siblings()