npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-rem

v1.0.3

Published

插件说明: 本插件的主要目的在于将设计稿尺寸完美的在设备上复现. 使我们在开发时只用关注于设计稿,不用对不同的屏幕尺寸的设备做过多的关注. 和阿里的lib-flexible有类似之处,不过简化和新增了一些在vue上能直接使用的接口

Downloads

2

Readme

vue-rem

插件说明:

本插件的主要目的在于将设计稿尺寸完美的在设备上复现.
使我们在开发时只用关注于设计稿,不用对不同的屏幕尺寸的设备做过多的关注.
和阿里的lib-flexible有类似之处,不过简化和新增了一些在vue上能直接使用的接口

安装: 

npm install vue-rem -S

使用: 
import rem from 'vue-rem'
Vue.use(rem, {
    design: 750,
    size: 100,
    minWidth:700
})
参数说明:

design表示设计尺寸,size表示的是缩放比例尺,比如size = 100时表示 实际使用尺寸缩小100倍,比如设计尺寸的750px,
这个时候如果设计稿上的一个区域的宽度为375px我们就写成3.75rem.
minWidth表示浏览器最小的宽度尺寸.当窗口小于该尺寸时,不再缩放.
#注意:如参数为空,默认design为750,size为100,minWidth为300.

属性和方法说明:

在vue生命中期中的任何位置均可调用以下属性或方法
this.$size.set()立即重新设置rem
this.$size.px(x)将x(x表示rem尺寸)转化为px尺寸,方便有些组件没有对rem兼容,我们手动转化尺寸再传入
this.$size.dpr获取当前设备的dpr,此时我们可以根据设备的dpr来选择不同分辨率的图片
this.$size.rem获取当前设备的根font-size

一个简单的例子:
<template lang='pug'>  
    div.back helloworld  
</template>  

<script>  
export default {  
    name: 'home',  
    data(){  
      return {  
          size:this.$size  
      }  
    },  
    watch:{  
        size:{  
            handler(x){  
                console.log(x.rem)  
            },  
            deep:true  
        }  
    }  
   }  

</script>  

<style lang='css' scoped>  
.back{  
    width: 2rem;  
    height: 2rem;  
    background: black  
}  
</style>  

此时我们调整浏览器的窗口会实时得到最新的根font-size.  
因此该插件能实时根据当前窗口的大小或方向实时更新根部的font-size