Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miniapp 笔记 #75

Open
amenzai opened this issue Oct 23, 2018 · 0 comments
Open

miniapp 笔记 #75

amenzai opened this issue Oct 23, 2018 · 0 comments

Comments

@amenzai
Copy link
Owner

amenzai commented Oct 23, 2018

小程序笔记

  • 注册账号、下载开发者工具
  • 新建项目
  • 基础与新特性
    • 4种文件类型
    • 项目结构
    • app.json 配置
    • wxml 与 组件(page.js component.js)
  • felx 布局
  • 组件初步
    • 定义、引用和使用组件
    • 相对路径、绝对路径
    • 尺寸单位
    • css 选择器
    • 组件只能继承少数全局样式
  • 组件数据、事件、属性
    • 父子组件通信
    • 数据绑定
    • properties 属性
  • 封装 API
    • wx.request()
    • wx.request-4xx状态码并不会执行fail
    • 同步、异步、回调、Promise
    • 通用错误处理

一些重点:

  • observer 功能:对 properties 监听,相当于 vue L里的 watch。
  • Behaviors 功能:相当于 vue 里的 mixins(理解覆盖原则,谁的优先级高)。
  • 循环使用不怎么更新的数据,使用缓存处理。
  • 同层级组件通信,可以先传给父组件在传递给子组件。
  • 插槽,外部样式(引用组件并覆盖其样式)
/* hack 方式 */
.comment-container > tag-cmp:first-child view {}

引用组件无法修改其内部样式,如何通过传参,来动态修改组件样式?

  • 组件 JS 设置:externalClasses:['tag-class'],
  • 组件 wxml:<view class='container tag-class'>
  • 引用组件时:<tag-cmp tag-class="tag">
  • 外部样式覆盖:样式后面加 !important

文本换行问题:

  • 使用 wxs 编写过滤器
  • wxml 中可以使用函数,封装那些复杂操作
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant