2 Star 1 Fork 0

liu / lcui-router

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

lcui-router

(English/中文)

GitHub Actions Build Status Coverage Status

介绍

LCUI Router 是 LCUI 的官方路由管理器。它和 LCUI 的核心深度集成,提供与 Vue Router 类似的开发体验,能让构建多视图的 LCUI 应用变得易如反掌。包含的功能有:

  • 嵌套的路由/视图表
  • 模块化的、基于组件的路由配置
  • 路由参数、查询、通配符
  • 细粒度的导航控制
  • 带有自动激活的 CSS class 的链接

安装

Windows:

使用 LCPkg 安装:

lcpkg install github.com/lc-soft/lcui-router

Linux:

假设你已经能够熟练的手动编译源代码,那么你只需下载此项目的源代码然后复制到你的项目目录里,与你的项目源代码一同编译。

快速上手

注意: 我们将使用 lcui-cli 工具来管理路由的配置和源代码。

创建一个 LCUI 应用程序项目:

lcui create myapp
cd myapp

复制以下代码并覆盖到文件 app/assets/views/app.xml

<?xml version="1.0" encoding="UTF-8" ?>
<lcui-app>
  <resource type="text/css" src="assets/stylesheets/app.css"/>
  <ui>
    <w>
      <textview>Hello App!</textview>
      <w>
        <!-- 使用 router-link 部件用于导航 -->
        <!-- 通过 `to` 属性来指定链接 -->
        <router-link to="/foo">Go to Foo</router-link>
        <router-link to="/bar">Go to Bar</router-link>
      </w>
      <!-- 路由出口 -->
      <!-- 与路由匹配的部件将会渲染在这里 -->
      <router-view />
    </w>
  </ui>
</lcui-app>

生成两个部件:

lcui generate widget foo
lcui generate widget bar

保存以下代码到文件 config/router.js:

module.exports = [
  { path: '/foo', component: 'foo' },
  { path: '/bar', component: 'bar' }
]

编译路由配置文件:

lcui compile router

运行应用程序:

lcpkg run start

如需更多示例,可查看 lcui-router-app 项目。

文档

LCUI Router 的设计参考自 Vue Router,因此,你可以通过阅读 Vue Router 的文档 来学习 LCUI Router 的简单用法。

许可

代码基于 MIT 许可协议 发布。

MIT License Copyright (c) 2019 Liu Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

LCUI 的官方路由管理器,代码设计参考自 Vue Router,用于解决 LCUI 应用内多视图的切换和状态管理问题。 展开 收起
C
MIT
取消

发行版 (1)

全部

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/lc-soft/lcui-router.git
git@gitee.com:lc-soft/lcui-router.git
lc-soft
lcui-router
lcui-router
master

搜索帮助