Skip to content

Instantly share code, notes, and snippets.

View lustan3216's full-sized avatar
🎯
Focusing

lululala lustan3216

🎯
Focusing
  • 接案工程師
  • 洗馬拉牙衫
View GitHub Profile
todos.length ? (
<ul>
{ todos.forEach(todo => todo && <li>{todo}</li>) }
</ul>
) : (
<p>No todos left!</p>
)
<ul v-if="todos.length">
<li v-for="todo in todos" v-if="todo"> // v-if here just for example to compare, although official not recommend like this
{{ todo }}
</li>
</ul>
<p v-else>No todos left!</p>
<template>
<p
class="foo"
:class="align"
:style="color: fontColor"
>
{{name}}
</p>
</template>
<script>
render(){
const { fontColor, align } = this.props
const { name } = this.state
return (
<p
className={`${fontColor} ${align} foo`}
style="color: fontColor"
>
{name}
<template>
<p>{{slogan}}</p>
</template>
<script>
props:['middName'],
data: {
firstName: 'I',
lastName: 'Cat'
},
<!-- the click events propagation will be stopped -->
<a @click.stop="doThis"></a>
<!-- the submit event will no longer reload the page -->
<form @submit.prevent="onSubmit"></form>
<!-- modifiers can be chained -->
<a @click.stop.prevent="doThat"></a>
<!-- just the modifier -->
var myMixin = {
created: function () {
this.hello()
},
methods: {
hello: function () {
console.log('hello from mixin!')
}
}
}
<template>
<div>
<select v-model="selected" multiple>
<option>Grapefruit</option>
<option>Lime</option>
<option>Coconut</option>
<option>Mango</option>
</select>
<span>Select value: {{ selected }}</span>
class Select extends React.Component {
state = {
selected: [],
fruits: [
{value: "banana", isChecked: false},
{value: "apple", isChecked: false},
{value: "mango", isChecked: false},
{value: "grap", isChecked: false}
]
};
<template>
<a class="primary">GitHub</a>
</template>
<style scoped>
a {
background: transparent;
color: white;
}
a.primary {