Skip to content

Instantly share code, notes, and snippets.

@imyelo
Last active March 9, 2018 09:38
Show Gist options
  • Save imyelo/48872fc76468c86b1feb893a98a216fa to your computer and use it in GitHub Desktop.
Save imyelo/48872fc76468c86b1feb893a98a216fa to your computer and use it in GitHub Desktop.
tinajs - intro example
<!-- /app.mina -->
<config>
{
"pages": [
"pages/home.mina",
]
}
</config>
<script>
import Tina from '@tinajs/tina'
import router from '@tinajs/tina-router'
Tina.use(router)
App()
</script>
<!-- /pages/home.mina -->
<config>
{
"usingComponent": {
"logo": "../components/logo.mina"
}
}
</config>
<template>
<view>
<text>I'm {{ name }}. </text>
<button bindtap="sayHi">Say Hi</button>
<logo />
</view>
</template>
<script>
import { Page } from '@tinajs/tina'
import { fetchUser } from '../api'
Page.define(({
data: {
firstname: 'Tina',
lastname: 'S',
},
// 由 tina 集成的计算属性能力
compute ({ firstname, lastname }) {
return {
name: `${firstname} ${lastname}`,
}
},
async onLoad () {
// 由 tina-router 提供的路由能力扩展
let { id } = this.$route.query
try {
let { firstname, lastname } = fetchUser(id)
this.setData({ firstname, lastname })
} catch (error) {
this.$router.redirect(`/pages/login?from=${this.$route.fullPath}`)
}
},
methods: {
sayHi () {
wechat.showModal({
title: `Hi ${this.data.name}`,
})
},
},
}))
</script>
<style>
view {
padding: 30px 20px;
}
button {
margin: 20px 0;
}
</style>
@imyelo
Copy link
Author

imyelo commented Mar 9, 2018

carbon setting

  • basic style
  • drop shadow
    • offset-y: 0
    • blur-radius: lower than padding (both v and h)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment