我正在尝试以秒精度绘制时间序列,格式为HH:mm:ss(24小时/天),如一下js docs中所述。
问题是我声明的格式没有得到遵守,我尝试了Chartsjs文档中的几种组合,但没有一种有效。
Vue.component('line-chart', {
extends: VueChartJs.Line,
mixins: [VueChartJs.mixins.reactiveProp],
props: ['chartData', 'timeFormat'],
data() {
return {
options: {
animation: false,
scales: {
xAxes: [{
type: 'time',
distribution: 'series',
time: {
format: this.timeFormat
}
}],
},
}
}
},
mounted () {
this.renderChart(this.chartData, this.options);
}
})
var vm = new Vue({
el: '.app',
data() {
return {
chart: {},
timeFormat: 'HH:mm:ss',
timeout: null,
len_data: 20
}
},
created () {
this.change_data();
},
methods: {
change_data: …Run Code Online (Sandbox Code Playgroud)我正在为此努力奋斗.我需要selected从FormComponent 访问ChooseLangComponent中的值.有没有直接的方法来做到这一点,或者我们必须从父组件传递它(像中间人一样)?我已经尝试使用$emitChooseLangComponent和v-on:..FormComponent,但没有工作.
ChooseLangComponent:
<template lang="html">
<div class="choose-lang">
<select v-model="selected">
<option v-for="lang in langs" v-bind:value="lang.value">{{lang.text}}</option>
</select>
</div>
</template>
<script>
export default {
data() {
return {
selected: 'en',
langs: [
{ text: 'English', value: 'en' },
{ text: 'German', value: 'ge' },
]
}
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
FormComponent:
<template lang="html">
<div class="form-name">
<div class="inputs">
<input type="text" v-model="nameText" v-on:keyup.enter="send_name">
</div>
</div>
</template>
export default {
data() {
return {
nameText: '',
}
},
methods: {
send_name() …Run Code Online (Sandbox Code Playgroud) 我认为这应该默认实施,因为我在routes/api.php.
我想给出 404 错误 JSON 响应,以防我们id在findOrFail()方法上找不到给定参数的任何行。
就像是:
return response()->json([
'status' => 'ERROR',
'error' => '404 not found'
], 404);
Run Code Online (Sandbox Code Playgroud)
而不是默认的Sorry, the page you are looking for could not be found.刀片页面。
我不想做:
$item = Model::find($id);
if (is_null($item)) {
return response()->json([
'status' => 'ERROR',
'error' => '404 not found'
], 404);
}
Run Code Online (Sandbox Code Playgroud)
在任何地方,当我得到一个id, 我不想在中间件中实现它,因为它会导致 api.php 文件出现一些“混乱”。