Giter VIP home page Giter VIP logo

tina's Introduction

Tina.js

一款轻巧的渐进式微信小程序框架

npm license PRs Welcome Chat

特性

  • 🐝 轻盈小巧

    核心框架打包后仅

  • 🙋 极易上手

    保留 MINA (微信小程序官方框架) 的大部分 API 设计;无论你有无小程序开发经验,都可以轻松过渡上手。

  • 📈 渐进增强

    我们已经为你准备好了 状态管理器 (比如 Redux)、Immutable.js路由增强 等扩展,当然你也可以 自己编写一个新的插件

NPM 与单文件组件

结合我们为你准备的 mina-webpack,还能够为你的小程序项目带来:

  • 🍢 Mina 单文件组件 / 页面
  • 📦 NPM(没错!除了一般的包,你还可以分享或下载独立的 Mina 组件)
  • 🔮 以及 Webpack 附带的其他能力,如 Babel、PostCSS、代码压缩等功能。

一个简单的例子

浏览更多示例

浏览更多使用 Tina.js 的示例 🔰

文档

如果你已经熟悉传统的小程序开发,那么上手 tina 将会非常简单。

接下来,请前往 📖 tina.js.org 查阅更详尽的指南。

Showcase

小程序码 项目
wxcode Hacker News 热点 🔥
https://github.com/tinajs/tina-hackernews
wxcode 快资讯
@lizheming
wxcode 即刻App
@ruguoapp
wxcode 选个电影
@leadream
wxcode 小鹿选房
fanggeek.com
wxcode 魔性壁纸 😀
neobaran.com
wxcode 和教育语智通 教师版
wxcode 库音 COOLVOX
coolvox.com
wxcode CHA蛋
chaotag.com

你也已经在使用 Tina.js 了吗?请在这里告诉我们 💪。

License

FOSSA Status

Apache-2.0 © yelo, 2017 - present

tina's People

Contributors

baranwang avatar callmesoul avatar cosformula avatar dependabot[bot] avatar fossabot avatar imyelo avatar jimexist avatar leadream avatar netputer avatar pymonar avatar strange-fish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tina's Issues

Couldn't use with wux-weapp

Am I doing it wrong?

Steps to reproduce

Install

npm i -S wux-weapp --production

Modified home.mina

{
  "usingComponents": {
    "wux-icon": "~wux-weapp/dist/icon/index",
    "wux-tabbar": "~wux-weapp/dist/tabbar/index",
    "wux-tabbar-item": "~wux-weapp/dist/tabbar-item/index"
  }
}

<wux-tabbar defaultCurrent="tab2">
  <wux-tabbar-item key="tab1" title="Tab 1">
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-on" />
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-off" />
  </wux-tabbar-item>
  <wux-tabbar-item key="tab2" title="Tab 2">
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-on" />
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-off" />
  </wux-tabbar-item>
  <wux-tabbar-item key="tab3" title="Tab 3">
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-on" />
    <wux-icon wux-class="icon" type="ios-home" size="22" slot="icon-off" />
  </wux-tabbar-item>
</wux-tabbar>

Browser errors

thirdScriptError 
 sdk uncaught third Error 
 Cannot assign to read only property 'exports' of object '#<Object>' 
 TypeError: Cannot assign to read only property 'exports' of object '#<Object>'

jsEnginScriptError
Component is not found in path "_/_node_modules_/wux-weapp/dist/tabbar/index" (using by "pages/home");onAppRoute
Error: Component is not found in path "_/_node_modules_/wux-weapp/dist/tabbar/index" (using by "pages/home")

https://github.com/wux-weapp/wux-weapp/

大大,我想问问还有其他使用tina框架的小程序吗

最近在看各种小程序框架,我倾向于使用微信原生组件,在此基础上扩展我们所需要的 所以看上了两个框架,一个是wxpage 腾讯视频推的框架,还有一个就是大大你的框架了,wxpage给我的感觉就是更轻,不过大大的框架带有一些单文件呀之类的,对开发更方便,只是看大大的官网,就看到一个现成的 使用tina框架的小程序 案例,想问问大大还有其他的 使用tina框架的小程序,我想体验体验

传参并返回上一页时数据没变化

上一页定义的数据:

data: {
    test: null
}

当前页设置上一页数据:

      let pages = getCurrentPages();
      let prevPage = pages[pages.length - 2];
      prevPage.setData({
          test: 'some test',
      })

上一页如果在wxml里有用到 {{ test }} ,数据确实发生了变化 ,但是当返回上一页时,console.log(this.data.test) 结果却是默认值 null 没有变化

用原来的 Page({}) 打印data数据是有变化的,用了 Page.define({}) 数据就为null了

bug: component 组件中定义的 data 数据对象被共享

例子

在page页面中引用了 2 次 form 组件,导致 formData 对象数据公用,当输入一个框时,第二个文本框值自动同步,surname 参数完好!

我在原生小程序中不会出现该问题。

// page
<template>
  <view>
    <form></form>
    <form></form>
</view>
</template>
// form component
<template>
  <view class="form-validate">
    <view class="form-item">
      <view class="label">
        <text class="red">*</text></view>
      <view class="box">
        <input type="text" maxlength="50" placeholder="请输入汉字姓" value="{{ surname }}" bindinput="surnameInputChange" />
      </view>
       <view class="box">
        <input type="text" maxlength="50" placeholder="请输入汉字姓" value="{{ formData.surname }}" bindinput="surnameformDataInputChange" />
      </view>
    </view>
  </view>
</template>

<script>
import { Component } from '@tinajs/tina'

Component.define({
  data: {
    formData: {
      surname: ''
    },
    surname: '',
    __deep__: true // 1
  },
 // 2
  // data() {
  //   return {
  //     formData: {
  //       surname: ''
  //     },
  //     surname: ''
  //   }
  // },
methods: {
    surnameformDataInputChange({ detail: { value } }) {
      this.data.formData['surname'] = value
      this.setData({
        formData: this.data.formData
      })
    },
    surnameInputChange({ detail: { value } }) {
      this.setData({
        surname: value
      })
    },
  }
});
</script>

目前解决方案

  • data 中加个 __deep__: true 来标示进行对 对象 深拷贝解决。
  function SigmundData(plain) {
    var _this = this;

    classCallCheck(this, SigmundData);

    forOwn(plain, function (value, key) {
      _this[key] = value;
+     if (plain && plain.__deep__) {
+       _this[key] = deepClone1(value);
+     }
    });

    Object.defineProperty(this, '__signatures', {
      enumerable: false,
      writable: true
    });

    this.sign();
  }

如果 data 可以定义是个函数来解决那就更好 🤔

tina 能够支持多页配置?

有这样一个需求:

同时要开发 & 维护两个小程序,期望将它们放在一个项目中,开发过程同多页面文件开发一样。
不知该如何配置,作者能够提供一下解决思路

谢谢

Component 组件不支持 pageLifetimes

我现在急需使用这个功能 😭

我看了源码中 /src/core/layers/component.js 是没有配置这个方法的吗

Component({
  pageLifetimes: {
    show: function() {
      // 页面被展示
    },
    hide: function() {
      // 页面被隐藏
    },
    resize: function(size) {
      // 页面尺寸变化
    }
  }
})

在set data 的时候不能trigger wxml 层的 class 中的 变量 更新

嗨 你好! 感谢开发这个框架 目前为止 非常好用 但是遇到一个问题无法解决

我尝试使用 Ripples.wxss 添加animation 一个常用的方法使用 setData 来控制 animation 比如 通过改变 data 中的 bounceShow 就可以给 以下 这个view 添加 bounce 动画
<view class="ripple {{bounceShow ? bounce:''}}">bounce</view>
但是 用了 tina.js 之后 无法看到 在 wxml 中的 data的更新 在这个例子中 bounceShow 一直不会被改变 能提供一些debug的思路吗? 感谢🙏

请问能不能支持把config放到script标签内部?

类似 wepy 那样。。。
提示这个 issues 的主要原因和 #55 是一样的,webstorm折腾了半天还是没法格式化 标签内的代码,自己又不会写插件。。。如果能把 config 放到 script 内,作为一种可选的形式,那就真的太感谢了

webpack配置怎么加上stylus-loader?

因为当前目录结构不大确定。
所以加上stylus-loader,可以使用~路径
这样样式文件与样式文件的引用就变成绝对路径,就算结构变换也不用去每个文件改引用路径。

但试了很久都报错。
请问怎么引入stylus-loader?

引入图片后报错

Module build failed (from ../node_modules/@tinajs/mina-loader/lib/index.js):
ModuleBuildError: Module build failed (from ../node_modules/@tinajs/wxml-loader/lib/index.js):
evalmachine.:1
export default webpack_public_path + "assets/driver.png";

引入图片报错了
<image src="../../images/driver.png" />

这个怎么解决啊

有没有模板增强计划,比如双向绑定

目前有js和style的增强,那么是否考虑下template的增强?比如非常实用的双向绑定。例如wx:model="someValue"=value="{{somevalue}}" bind:input="onInput"这样的辅助写法。

parseInt 和parseFloat都用不了的?

为什么parseIntparseFloat都用不了的?

thirdScriptError 
 sdk uncaught third Error 
 $parseFloat is not a function 
 TypeError: $parseFloat is not a function
    at Object.300 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:205:22)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.299 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:192:19)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.298 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:182:1)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Object.297 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:175:18)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)
    at Module.266 (http://127.0.0.1:14521/appservice/pages/notice/detail.js:15:100)
    at __webpack_require__ (http://127.0.0.1:14521/appservice/runtime.js:79:30)

当文件数超过一定数量时遭遇 npm start 失败

➜  yaodd-wxlite git:(master) ✗ npm run start

> [email protected] prestart /Users/zhuozhongcao/Desktop/Projects/yaodd/yaodd-wxlite
> run-s clean


> [email protected] clean /Users/zhuozhongcao/Desktop/Projects/yaodd/yaodd-wxlite
> rimraf "./dist/!(app.json|project.config.json)**"


> [email protected] start /Users/zhuozhongcao/Desktop/Projects/yaodd/yaodd-wxlite
> webpack -w


Webpack is watching the files…

➜  yaodd-wxlite git:(master) ✗

运行npm run start的时候会自动结束

image

但是只要把app.mina里面pages随便删掉两行就一切正常了

image

插件模式下 mixin 失效

在开发小程序插件中,使用全局 mixin 方法失效

plugin.mina
pages
- index.main

plugin.mina

<config>
{
  "pages":{
    "index": "pages/index.mina",
  },
  "main": "plugin.js"
}
</config>

<script>
import { Page, Component } from '@tinajs/tina'

const isx = /iphone10|iphone11|iphone x/i.test(wx.getSystemInfoSync().model)
const data = { isx }

Page.mixin({ data })
Component.mixin({ data })
</script>

引入插件怎么用绝对路径?

因为分的目录比较多,用相对路径麻烦,也不便于以后的修改维护。
怎么使用绝对路径呢?我用@ 或者~@都不行

{
  "navigationBarTitleText":"书单列表",
  "usingComponents": {
    "book-list":"../../components/library/book-list/book-list.mina",
    "scroller-pagination":"../../components/scroller-pagination/scroller-pagination.mina",
  }
}

{
  "navigationBarTitleText":"书单列表",
  "usingComponents": {
    "book-list":"@/components/library/book-list/book-list.mina",
    "scroller-pagination":"~@/components/scroller-pagination/scroller-pagination.mina",
  }
}

依赖包中的图片资源不能被编译

背景

引入三方小程序原生UI组件

yarn add lin-ui

三方组件应用

使用 lin-ui 提供的组件, lin-ui

<config>
{
  "component": true,
  "usingComponents": {
    "tab-bar": "./tab-bar.mina",
    "l-capsule-bar": "~lin-ui/dist/capsule-bar/index"
  }
}
</config>

<template>
  <view>
    <l-capsule-bar bg-color="#25798a" home-page="pages/home/index" title="title">
      <slot></slot>
    </l-capsule-bar>
    <tab-bar />
  </view>
</template>

<script>
import { Component } from '@tinajs/tina'
Component.define({
})
</script>

问题

渲染视图中, 组件 l-capsule-bar 引用的 本地图片, 为正常编译
image
image

临时解决

cp -rf node_modules/lin-ui/dist/capsule-bar/icons ./dist/_/_node_modules_/lin-ui/dist/capsule-bar/

image

期望

期望 tinajs 可以自动打包三方组件中的静态资源.

sao mina my-app 报错

使用sao 0.22.17可以正常安装, 但sao目前的版本1.2.0会报错。

npm ERR! 404 Not Found: sao-mina@latest

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/tmg2017/.npm/_logs/2018-11-13T08_33_20_683Z-debug.log
/usr/local/lib/node_modules/sao/lib/installPackages.js:89
        throw new SAOError(`Failed to install ${packageName} in ${cwd}`)
        ^

Error: Failed to install sao-mina@latest in /Users/tmg2017/.sao/V1/packages/4bbaad60
    at ChildProcess.ps.on.code (/usr/local/lib/node_modules/sao/lib/installPackages.js:89:15)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Socket.stream.socket.on (internal/child_process.js:346:11)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at Pipe._handle.close [as _onclose] (net.js:557:12)

自动引入组件需求

总所周知,小程序不支持全局的组件跟api,所以自己写的自动定义组件在页面上用时总是要很繁琐的地一个个去引用组件。
最近看了别人的一个vue项目,就是全局组件在一个目录下,会自动注册成全局组件。

于是想tina能不能使用 webpack,在页面tempalte查找使用的自定义组件节点,去自动查找引入自定义组件了,这样就不用一个个引用了 。对于自定义顶部导航等全局的组件来说方便 多了

Page缺少getOpenerEventChannel()

https://developers.weixin.qq.com/miniprogram/dev/api/route/wx.navigateTo.html

import { Page } from "tina.min.js";

Page.define({
  onLoad() {
    const eventChannel = this.getOpenerEventChannel() // is not a function
    console.log(eventChannel)
  }
})
Page({
  onLoad() {
    const eventChannel = this.getOpenerEventChannel()
    console.log(eventChannel) // {listener: {…}, emit: ƒ, on: ƒ, once: ƒ, off: ƒ, …}
  }
})
import { Page } from "tina.min.js";

Page.define({
  onLoad() {
    const eventChannel = this.$source.getOpenerEventChannel()
    console.log(eventChannel) // {listener: {…}, emit: ƒ, on: ƒ, once: ƒ, off: ƒ, …}
  }
})

组件没法使用新的lifetimes生命周期字段

定义生命周期方法
生命周期方法可以直接定义在 Component 构造器的第一级参数中。

自小程序基础库版本 2.2.3 起,组件的的生命周期也可以在 lifetimes 字段内进行声明(这是推荐的方式,其优先级最高)。

代码示例:

Component({
  lifetimes: {
    attached() {
      // 在组件实例进入页面节点树时执行
    },
    detached() {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  // 以下是旧式的定义方式,可以保持对 <2.2.3 版本基础库的兼容
  attached() {
    // 在组件实例进入页面节点树时执行
  },
  detached() {
    // 在组件实例被从页面节点树移除时执行
  },
  // ...
})

tina 的 component 支持旧的,不支持新的

项目引入 echarts-for-weixin 库,webpack 编译报错

TypeError: Class constructor WebpackError cannot be invoked without 'new'。

该库不需要使用 new 来创建,应该如何解决呢。

// https://github.com/ecomfe/echarts-for-weixin/blob/master/pages/bar/index.js

chart = echarts.init(canvas, null, {
    width: width,
    height: height
  });

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.