๐
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template lang="pug"> | |
div.list | |
span {{translate('global.lang')}} | |
label(v-for="lang in available").item | |
input(type="radio",v-model="current",:value="lang") | |
img(:src="icon(lang)",:class="{active: lang === current}") | |
</template> | |
<script> | |
export default { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { required, numeric } from 'vuelidate/lib/validators' | |
import { buildFromValidator } from '@/common/utils/forms' | |
const form = { | |
name: { required }, | |
weapon: { required }, | |
price: { numeric }, | |
image: { required }, | |
nested: { | |
item: { required, numeric } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
data: () => ({ | |
form: { | |
name: null, | |
surname: null, | |
age: null | |
} | |
}), | |
validations: { | |
form: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default { | |
forms: { | |
form: { | |
name: { required }, | |
surname: { required }, | |
age: { | |
required, | |
min: value => value >= 18 | |
}, | |
// That one will have a default value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Container } from 'apicase' | |
// Declare headers | |
const headers = () => ({ | |
token: localStorage.getItem('token') | |
}) | |
// Declare services | |
const services = { | |
hello: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
this.$form('test').reset() // Reset previous state for form | |
this.$form('test').validate() // Call $touch() + return !$invalid |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<div v-if="apis.hello.pending">Loading</div> | |
<div v-else> | |
<button @click="$api.go('hello')">Hello</button> | |
</div> | |
</div> | |
</template> | |
<script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<form @submit.prevent="$form('testForm').submit('hello')"> | |
<h2> Vuelidate-forms + Vue-Apicase demo</h2> | |
<label> My name is </label> | |
<input | |
type="text" | |
v-model="test.name" | |
@input="$v.test.name.$touch" | |
:class="{ invalid: $v.test.name.$invalid && $v.test.name.$dirty }" | |
placeholder="Enter your name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Example of boilerplate api call */ | |
let res = await get('/posts') | |
if (res.success) { | |
/* | |
Place data somewhere, success alert etc. | |
I really feel sorry for people | |
who still writes so in every call | |
just copy-paste and don't worry about | |
And I pretty sure that most of you will say | |
"Wtf do you talk? There is no another way" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import axios from './axios-custom' | |
export const foo = () => axios.get('/foo/bar/') | |
export const products = { | |
get: id => | |
axios.get(`/products/${id}`), | |
save: (data, id = null) => |
OlderNewer