All Projects → cpagejs → Cpage.js

cpagejs / Cpage.js

Cpage.js是一款轻量级的前端框架,使用TypeScript开发,可以方便地进行组件化开发,语法统一、简介明了,不依赖于第三方框架,适合中小项目开发。框架同时支持es5与es6语法,可参考example中示例。

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
js
455 projects

Labels

Projects that are alternatives of or similar to Cpage.js

Topcorn
A minimalistic movie listing app to browse IMDB's top 250 movies, built to demonstrate MVVM with latest hot-trending Android development tools.
Stars: ✭ 131 (-11.49%)
Mutual labels:  mvvm
Foodium
It simply loads Posts data from API and stores it in persistence storage (i.e. SQLite Database). Posts will be always loaded from local database. Remote data (from API) and Local data is always synchronized.
Stars: ✭ 1,940 (+1210.81%)
Mutual labels:  mvvm
Xamu Infrastructure
Extensions, MVVM classes, behaviors and other misc. useful code bits from Xamarin University
Stars: ✭ 144 (-2.7%)
Mutual labels:  mvvm
Steamtools
🛠「Steam++」是一个开源跨平台的多功能Steam工具箱。
Stars: ✭ 4,458 (+2912.16%)
Mutual labels:  mvvm
Webcell
Web Components engine based on JSX & TypeScript
Stars: ✭ 139 (-6.08%)
Mutual labels:  mvvm
Popularmovies
🎥 Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.
Stars: ✭ 142 (-4.05%)
Mutual labels:  mvvm
Bindables
🧬 Android DataBinding kit for notifying data changes from Model layers to UI layers on MVVM architecture.
Stars: ✭ 130 (-12.16%)
Mutual labels:  mvvm
Android Vmlib
VMLib is an Android framework based on Android Jetpack, easy to use, desinged for fast development. Embrace the new way devloping Android :)
Stars: ✭ 146 (-1.35%)
Mutual labels:  mvvm
Unio
🔄 KeyPath based Unidirectional Input / Output framework with RxSwift.
Stars: ✭ 139 (-6.08%)
Mutual labels:  mvvm
Androidmodulararchiteture
✔️ Android组件化架构,支持组件代码完全隔离/组件循环依赖/便捷集成调试/快速接入,组件内基于 mvvm结构,组件提供高度服用的模块可直接使用,采用 wanAndroid api进行迭代开发。Android componentized architecture, support component code complete isolation / component circular dependency / convenient integrated debugging / fast access, component based mvvm structure, iterative development using wanAndroid api
Stars: ✭ 144 (-2.7%)
Mutual labels:  mvvm
Combine Mvvm
Sample project with Combine & UIKit framework, MVVM architecture
Stars: ✭ 132 (-10.81%)
Mutual labels:  mvvm
Android Clean Architecture Mvvm Dagger Rx
Implemented by Clean Architecture, Dagger2, MVVM, LiveData, RX, Retrofit2, Room, Anko
Stars: ✭ 138 (-6.76%)
Mutual labels:  mvvm
Android Template
Android app starter template
Stars: ✭ 141 (-4.73%)
Mutual labels:  mvvm
Rxcommand
A UI-related rxjava component for android mvvm architecture
Stars: ✭ 131 (-11.49%)
Mutual labels:  mvvm
Monkey
Monkey is an unofficial GitHub client for iOS,to show the rank of coders and repositories.
Stars: ✭ 1,765 (+1092.57%)
Mutual labels:  mvvm
Cocktailapp
Cocktails Android App with Clean Architecture, MVVM , Retrofit, Coroutines, Navigation Components , Room, Dagger Hilt, Cache Strategy and Coroutines Flow
Stars: ✭ 128 (-13.51%)
Mutual labels:  mvvm
Mvvmvalidation
Lightweight library that helps reduce boilerplate when implementing validation in XAML MVVM applications
Stars: ✭ 141 (-4.73%)
Mutual labels:  mvvm
Ktarmor Mvvm
👻 Android快速开发框架, KtArmor 寓意着 为Android 赋予战斗装甲, 方便开发者快速进行Android 开发。
Stars: ✭ 148 (+0%)
Mutual labels:  mvvm
Knockout Spa
A mini but full-fledged SPA framework and boilerplate to build SPAs fast and scalable
Stars: ✭ 145 (-2.03%)
Mutual labels:  mvvm
Beaver
Android MVVM + Dagger 2 (Hilt) + JetPack project template
Stars: ✭ 144 (-2.7%)
Mutual labels:  mvvm

文档地址:https://cpagejs.github.io/cpage/

Cpage.js

Cpage.js是一款轻量级的前端框架,使用TypeScript开发,可以方便地进行组件化开发,语法统一、简介明了,不依赖于第三方框架,适合中小项目开发。框架同时支持es5与es6语法,可参考example中示例。

安装

es6  npm install cpage
     import Cpage,  { Component } from 'cpage'; 
es5  <script src="https://cpagejs.github.io/source/cpage/bundle.js"></script>

组件(es5)

var app = Cpage.component({
    name: 'app',
    components: [],
    template: `<div>{{header}}--{{height}}</div>`,
    data: {
        header: 'this is header'
    },
    props: {
        height: {
            default: 10
        }
    },
    beforeRender() {
        console.log('beforeRender')
    },
    render() {
        console.log('render')
    }
});
Cpage.bootstrap("#app", app);

组件(es6)

import Cpage,  { Component } from 'cpage';
const html = require('./app.html');

export default class App extends Component {
    constructor(){
        super();
        this.name = 'app';
        this.data = {};
        this.templateUrl = html;
    }
    handelC(event){
        this.$event.trigger('header-event', 'header');
    }

    render(){
        
    }
}
Cpage.bootstrap('#app', App);

路由

路由需要使用<div c-view></div> | 方法名 | 用法 | | :------ | :------ | | go() | this.$router.go({path='', params={}}),跳转到已存在的路由页面 | | hash() | this.$router.hash(str),此方法可以更改页面的hash路由 | | reflesh() | this.$router.reflesh(),刷新当前路由 | | back() | this.$router.back(),返回 | 路由示例

Cpage.router([
    {
        path: '/',
        component: Header
    },
    {
        path: '/article',
        component: Article,
        params: {
            id: 123
        },
        cache: true,
        delay: 2000
    },
    {
        path: '/article/:id',
        component: ArticleList
    },
    {
        path: '/about',
        component: About,
        cache: true,
    },
    {
        path: '/footer/oo',
        component: Footer
    }
]);

注册路由之后,可以在组件内使用路由相关函数。

属性

属性名 是否必须 类型 用途
name 字符串 组件名称
components 数组 子组件名称集合
data 对象 组件属性
props 对象 用于子组件与父组件之间的数据传递
style 字符串 组件样式
styleId 字符串,id选择符 组件样式,es5语法
styleUrl 数组或对象 组件样式,es6语法,支持import * as css from ''; 或者require('../style.css'),需要引入css-loader
template 字符串 组件模板,es5,es6通用
templateId 字符串,id选择符 组件模板,es5语法
templateUrl 数组或对象 组件模板,es6语法,支持import * as html from ''; 或者require('../xx.html'),需要引入html-loader

方法

方法名 是否必须 用途
beforeRender 组件完成渲染之前执行
render 组件完成渲染之后执行
bootstrap Cpage对象的静态方法,用于将组件渲染到dom中

表达式

支持文字,运算符,变量 {{1+2}} 或者 {{text}} 表达式的变量与组件的data或props属性对应

指令

指令名 用法 用途
c-事件名 c-event="handel()" event可以为click,mouseover... 用于dom的事件绑定
c-for c-for="item in items" 用于循环输出指定次数的 HTML 元素,表达式必须是数组
c-if c-if="{{id>10}}" 表达式为true,则渲染节点;否则不渲染
c-show c-show="{{id>10}}" 表达式为true,则显示节点;否则隐藏
c-ref c-ref="btn" 节点标识符
c-html c-html="span" 将表达式内的字符替换节点的html

组件操作

方法名 应用范围 用途
$data 整个组件生命周期 修改组件的data属性,例:this.$data('text', 'new text')
$el 组件渲染完毕之后才能使用 组件节点
$refs 组件渲染完毕之后才能使用 单个dom节点,例:this.$refs['the-ele'],需要配合c-ref使用
$http 整个组件生命周期 操作http,例:this.$http.ajax({})。支持ajax(),get(),post()等操作
$event 整个组件生命周期 事件触发和监听,例:this.$event.trigger(事件名,信息) this.$event.listen(事件名, 回调函数)

DOM操作

Cpage.js提供建议的dom操作方式 es6语法

import { Dom } from 'cpage';

Dom('body').css('width')
Dom('body').width('100px')
Dom('body').hasClass('dom')
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].