Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rax-view

Package Overview
Dependencies
Maintainers
1
Versions
111
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rax-view

View component for Rax.

  • 2.0.6-3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
178
decreased by-50.28%
Maintainers
1
Weekly downloads
 
Created
Source

rax-view

npm

支持

Web / Weex / 阿里小程序 / 微信小程序 / 字节跳动小程序

描述

View 是最基础的组件,它支持 Flexbox、touch handling 等功能,并且可以任意嵌套。 不论在什么容器中,View 都直接对应一个容器的原生视图,就像 web 中的 div 一样。 支持任意自定义属性的透传。

安装

$ npm install rax-view --save

属性

属性类型默认值必填描述支持
classNamestring-false自定义样式名browser weex miniApp wechatMiniprogram
styleCSSProperties-false自定义样式browser weex miniApp wechatMiniprogram
onClickfunction-false点击browser weex miniApp wechatMiniprogram
onLongpressfunction-false长按weex miniApp wechatMiniprogram
onAppearfunction-false当前元素可见时触发browser weex miniApp
onDisappearfunction-false当前元素从可见变为不可见时触发browser weexminiApp
onTouchStartfunction-false触摸动作开始browser weexminiApp wechatMiniprogram
onTouchMovefunction-false触摸后移动browser weexminiApp wechatMiniprogram
onTouchEndfunction-false触摸动作结束browser weexminiApp wechatMiniprogram
onTouchCancelfunction-false触摸动作被打断,如来电提醒,弹窗browser weexminiApp wechatMiniprogram
import { createElement, useRef, useEffect, render } from "rax";
import DU from "driver-universal";
import View from "rax-view";

const App = () => {
  const viewRef = useRef(null);
  useEffect(() => {});
  return (
    <View
      ref={viewRef}
      style={{
        padding: '30rpx'
      }}
      onClick={() => {
        alert("container was clicked!");
      }}
    >
      <View
        style={{
          width: '300rpx',
          height: '300rpx',
          backgroundColor: "red"
        }}
        onClick={e => {
          e.stopPropagation();
          alert("red was clicked");
        }}
      />
      <View
        style={{
          width: '300rpx',
          height: '300rpx',
          backgroundColor: "green",
          position: "absolute",
          top: '20rpx',
          left: '20rpx'
        }}
        onClick={() => {
          alert("green was clicked");
        }}
      />
      <View
        style={{
          width: '300rpx',
          height: '300rpx',
          backgroundColor: "yellow",
          position: "absolute",
          top: '80rpx',
          left: '210rpx'
        }}
        onClick={e => {}}
      />
    </View>
  );
};

render(<App />, document.body, { driver: DU });

默认样式

rax-view 默认样式如下:

.rax-view-v2 {
   box-sizing: border-box;
   display: flex;
   flex-direction: column;
   flex-shrink: 0;
   align-content: flex-start;
   border: 0 solid black;
   margin: 0;
   padding: 0;
   min-width: 0;
}

Keywords

FAQs

Package last updated on 25 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc