我的第一个组件是这样的:
<template>
...
</template>
<script>
export default {
...
methods: {
addPhoto() {
const data = { id_product: this.idProduct}
const item = this.idImage
this.$store.dispatch('addImage', data)
.then((response) => {
this.createImage(item, response)
});
},
}
}
</script>
Run Code Online (Sandbox Code Playgroud)
如果调用方法addPhoto,它将调用ajax然后它将获得响应ajax
我想将响应ajax和另一个参数发送到方法createImage.方法createImage位于其他组件(第二个组件)中
我的第二个组件是这样的:
<template>
<div>
<ul class="list-inline list-photo">
<li v-for="item in items">
<div v-if="clicked[item]">
<img :src="image[item]" alt="">
<a href="javascript:;" class="thumb-check"><span class="fa fa-check-circle"></span></a>
</div>
<a v-else href="javascript:;" class="thumb thumb-upload"
title="Add Photo">
<span class="fa fa-plus fa-2x"></span>
</a>
</li>
</ul>
</div>
</template>
<script>
export default {
...
data() …Run Code Online (Sandbox Code Playgroud) 从这里:Laravel 5.4 - 如何自定义通知电子邮件布局?
我尝试自定义通知邮件布局
我的代码发送这样的电子邮件:
public function toMail($notifiable)
{
return (new MailMessage)
->subject('Test')
->view('vendor.mail.markdown.message',['data'=>$this->data]);
}
Run Code Online (Sandbox Code Playgroud)
像这样的观点:
@component('mail::layout')
{{-- Header --}}
@slot('header')
@component('mail::header', ['url' => config('app.url')])
{{ config('app.name') }}
@endcomponent
@endslot
{{-- Body --}}
{{ $slot }} test
{{-- Subcopy --}}
@isset($subcopy)
@slot('subcopy')
@component('mail::subcopy')
{{ $subcopy }}
@endcomponent
@endslot
@endisset
{{-- Footer --}}
@slot('footer')
@component('mail::footer')
© {{ date('Y') }} {{ config('app.name') }}. All rights reserved.
@endcomponent
@endslot
@endcomponent
Run Code Online (Sandbox Code Playgroud)
如果执行代码,则存在如下错误:
(2/2)ErrorException没有为[mail]定义提示路径.(查看:C:\ xampp\htdocs\myshop\resources\views\vendor\mail\markdown\message.blade.php)
我该如何解决错误?
我试着这样:
<div class="media-body">
@foreach($categories as $category)
@php $category[] = $category->name @endphp
@endforeach
{{ implode(",", $category) }}
</div>
Run Code Online (Sandbox Code Playgroud)
如果代码执行,则存在错误:
取消定义变量类别
我该如何解决?
我的对象数组($ c)像这样:
Array
(
[0] => stdClass Object
(
[id] => 3
[name] => chelsea.png
)
[1] => stdClass Object
(
[id] => 4
[name] => arsenal.png
)
[2] => stdClass Object
(
[id] => 5
[name] => mu.png
)
[3] => stdClass Object
(
[id] => 1
[name] => city.png
)
)
Run Code Online (Sandbox Code Playgroud)
我想按编号排序
如果在PHP正常我尝试这样:
function sort_by_id( $a, $b )
{
if( $a->id == $b->id ){ return 0 ; }
return ($a->id < $b->id) ? -1 : 1;
}
usort($c,'sort_by_id'); …Run Code Online (Sandbox Code Playgroud) 我的代码是这样的:
<div id="app">
<div v-for="item in items">
<div v-if="!image">
<h2>Select an image</h2>
<input type="file" @change="onFileChange">
</div>
<div v-else>
<img :src="image" />
<button @click="removeImage">Remove image</button>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
演示和完整代码如下:https : //codepen.io/moschel26/pen/jwdMgp
有5个输入文件。我想当我在输入文件 3 上上传图像时,图像只显示在 img 3 上。当我在输入文件 5 上上传图像时,图像只显示在 img 5 上。等等
我怎样才能做到这一点?
我知道解决方案是像这样更新prop数据:
this.selectedContinent = ""
Run Code Online (Sandbox Code Playgroud)
但我想使用另一种解决方案
在阅读了一些参考资料之后,解决方案是:
this.$forceUpdate()
Run Code Online (Sandbox Code Playgroud)
我尝试了,但是没有用
演示和完整代码如下:
https://jsfiddle.net/Lgxrcc5p/13/
您可以单击按钮测试来尝试
除了更新属性数据外,我还需要其他解决方案
我使用 Laravel 5.6
我试试这个文档:https : //laravel.com/docs/5.6/pagination
我的控制器是这样的:
public function index()
{
$products = $this->product->list();
dd($products);
return view('admin.product.index',compact('products'));
}
Run Code Online (Sandbox Code Playgroud)
我的列表功能是这样的:
public function scopeList($query)
{
return $query->orderBy('updated_at', 'desc')->paginate(20);
}
Run Code Online (Sandbox Code Playgroud)
如果我dd($products);,结果是这样的:
在视图 laravel 上,我添加了以下内容:
{{ $products->links() }}
Run Code Online (Sandbox Code Playgroud)
然后我上网查,结果为空
为什么结果是空的?
有什么不对?
如果图像未显示,请访问此处:https : //postimg.org/image/w39usbfrv/
我的脚本JavaScript是这样的:
<script>
var customer = {"name":"John", "address":'London'};
var products = [
{"product_name":"clothes", "quantity":1, "price":1000},
{"product_name":"trousers", "quantity":1, "price":500},
{"product_name":"shoes", "quantity":1, "price":2000}
];
</script>
Run Code Online (Sandbox Code Playgroud)
我想连接对象.所以我想要这样的结果:
我该怎么做?
我想在我的 vuetify 项目中添加 google recaptcha 3
谷歌 recaptcha 3 像这样:
我从这里得到参考:https : //www.npmjs.com/package/vue-recaptcha-v3
第一:我跑 npm install vue-recaptcha-v3
第二:我像这样修改我的 main.js:
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './registerServiceWorker'
import vuetify from './plugins/vuetify'
import { VueReCaptcha } from 'vue-recaptcha-v3'
Vue.config.productionTip = false
Vue.use(VueReCaptcha, {
siteKey: '<site key>',
loaderOptions: {
useRecaptchaNet: true
}
})
new Vue({
router,
store,
vuetify,
render: h => h(App),
methods: {
recaptcha() {
this.$recaptcha('login').then((token) => {
console.log(token) // …Run Code Online (Sandbox Code Playgroud) recaptcha vue.js vue-component vuetify.js react-google-recaptcha
我正在尝试在 Vuetify 上设置验证规则v-file-input以将文件大小限制为 2MB,但是当我选择 2MB 以下的文件时,验证错误地失败(并且出现输入错误)。
我的Codepen摘录:
<v-file-input
multiple
:rules="rules"
accept="image/jpg, image/jpeg, application/pdf"
placeholder="Pick an avatar"
prepend-icon="mdi-camera"
label="Avatar"
></v-file-input>
<script>
//...
data: () => ({
rules: [
value => !value || value.size < 2000000 || 'Avatar size should be less than 2 MB!',
],
}),
//...
</script>
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
vue.js ×5
laravel ×4
php ×3
vuejs2 ×3
vuex ×3
laravel-5.3 ×2
vuetify.js ×2
arrays ×1
email ×1
file-upload ×1
implode ×1
javascript ×1
laravel-5.4 ×1
laravel-5.6 ×1
object ×1
pagination ×1
recaptcha ×1
sorting ×1