vue.js是否有document.getElementById('#id')类似JQuery的速记$('#id')?
如果是这样,在文档中对此的引用在哪里,以便我可以找到其他信息?
我希望得到下周一或周四的日期(如果是周一或周四,则为今天).由于Moment.js在星期日 - 星期六的范围内工作,我必须在当天计算并根据以下计算下周一或周四:
if (moment().format("dddd")=="Sunday") { var nextDay = moment().day(1); }
if (moment().format("dddd")=="Monday") { var nextDay = moment().day(1); }
if (moment().format("dddd")=="Tuesday") { var nextDay = moment().day(4); }
if (moment().format("dddd")=="Wednesday") { var nextDay = moment().day(4); }
if (moment().format("dddd")=="Thursday") { var nextDay = moment().day(4); }
if (moment().format("dddd")=="Friday") { var nextDay = moment(.day(8); }
if (moment().format("dddd")=="Saturday") { var nextDay = moment().day(8); }
Run Code Online (Sandbox Code Playgroud)
这有效,但肯定有更好的方法!
(Vue.js新手)我从get请求中获取数据以显示日历信息.我希望每5分钟更新一次.
关于自动重装的文档中没有任何内容 - 我将如何实现这一点?我是否在文件或其他内容中使用标准JavaScript?
我的完整app.js如下:
Vue.component('events', {
template: '#events-template',
data: function() {
return {
list: []
}
},
created: function() {
this.fetchEventsList();
},
methods: {
fetchEventsList: function() {
this.$http.get('events', function(events) {
this.list = events;
}).bind(this);
}
}
});
new Vue({
el: 'body',
});
Run Code Online (Sandbox Code Playgroud) 使用v-on:click我想在Vue.JS中设置一个带有div的id的变量 - 我该如何引用它?
<div id="foo" v-on:click="select">...</div>
<script>
new Vue({
el: '#app',
data: {
},
methods: {
select: function(){
divID = this.id // ??
alert(divID)
}
}
})
</script>
Run Code Online (Sandbox Code Playgroud) 我正在使用(非官方)谷歌翻译TTS api来检索mp3以支持残疾学习者阅读网页.一切正常,但我们有美国口音(我们在英国!).然而,当我使用Google翻译时,它会以英国口音取出mp3 - 我该如何调用此行为?
我使用了相同的GET请求URL,所以我可以假设它不是这样的:
http://translate.google.com/translate_tts?q=testing+1+2+3&tl=en
Run Code Online (Sandbox Code Playgroud)
(我玩过其他语言代码(en-gb)但没有运气 - 但是对于法语来说却很有用.)
非常感谢
Laravel 5.5 find($ id)返回集合而不是单个对象
知道为什么,以及如何防止这种情况?我不得不使用->first()解决方法
public function destroy(client $client)
{
$item = Client::findOrFail($client)->first();
$item->delete();
session()->flash('message', 'Client deleted');
return redirect('/clients');
}
Run Code Online (Sandbox Code Playgroud) 我的$addresses数组为每个数组包含多个位置$client。这些地址是使用Laravel中的雄辩关系获取的。
我想获取每个地址,发现距原点的距离(使用Google Maps API),然后将该距离添加回每个对象。
我可以遍历每个键并重新添加新数据,但是有没有更简单的方法来读取邮政编码,获取距离并将其添加到每个键中?
$client = client::find($id);
$addresses = $client->address()->get();
Run Code Online (Sandbox Code Playgroud)
长发方法:
foreach ($addresses as $address) {
$newAddress= new \stdClass;
$newAddress->label = $address->label; //seems redundant
$newAddress->street= $address->street; //seems redundant
$newAddress->postcode = $address->postcode; //seems redundant
$newAddress->distance = (function to get distance) //this is the only new data
$newAddresses[] = $newAddress;
}
Run Code Online (Sandbox Code Playgroud) Gmail 文档说我需要create a MIME email messages compliant with RFC 2822. - https://developers.google.com/gmail/api/guides/sending
鉴于我只有一个“收件人”地址、主题和纯文本正文 - 是使用 SwiftMailer(或替代包)实现这一目标的最简单方法吗?
如果是这样,我如何确保 SwiftMailer 的输出适合 Gmail REST API?
我将使用此函数对它进行 Base64URL 编码:
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
Run Code Online (Sandbox Code Playgroud) If I remove the v-model attribute, checked works.
<input type="radio" name="sign" value="+" v-model="sumType" checked="checked"> Addition
<input type="radio" name="sign" value="-" v-model="sumType"> Subtraction
Run Code Online (Sandbox Code Playgroud)
How do I default check a radio button that has a vue js model attribute?
我想从数据库中获取所有用户,除了2.
我以前用这个代码抓住除了一个以外的所有:
$users = User::where('name', '!=','name1')->get();
Run Code Online (Sandbox Code Playgroud)
但我不确定如何为此添加其他名称.
非常感谢,
麦克风
文件夹结构:
Livewire
- Things
- Addthing.php
Run Code Online (Sandbox Code Playgroud)
刀片锉刀
@livewire('things.addthing')
Run Code Online (Sandbox Code Playgroud)
无法找到它:Unable to find component: [things.addthing]
没有子目录,这可以正常工作:
Livewire
- Addthing.php
Run Code Online (Sandbox Code Playgroud)
。
@livewire('addthing')
Run Code Online (Sandbox Code Playgroud)
如何让 Livewire 组件在子目录中工作?
根据文档,我应该能够使用update() https://laravel.com/docs/5.4/queries#updates更新记录,但我收到错误Method update does not exist.
Client::findOrFail($id)->update($request->all());
Run Code Online (Sandbox Code Playgroud)
知道为什么吗?
不知道我在这里错过了什么,但我所做的一切似乎都不允许@push('styles')或@push ('scripts')不起作用。
layout/app.blade.php包括:
...
@livewireStyles
...
@livewireScripts
...
Run Code Online (Sandbox Code Playgroud)
livewire/tagify.blade.php
@push('styles')
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@yaireo/tagify@3.11.1/dist/tagify.min.css">
@endpush
@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/@yaireo/tagify@3.11.1/dist/tagify.min.js"></script>
<script>
document.addEventListener("DOMContentLoaded", function(event) {
var input = document.getElementById('tagify')
var tagify = new Tagify(input, {
whitelist : [
@foreach($tags as $tag)
'{{ $tag }}'@if(! $loop->last), @endif
@endforeach
]
})
input.addEventListener('change', onChange)
function onChange(e){
@this.call('changeTags', e.target.value)
}
})
</script>
@endpush
Run Code Online (Sandbox Code Playgroud)
组件的其余部分都包含在内。
laravel ×6
php ×5
vue.js ×4
eloquent ×3
javascript ×3
arrays ×1
checked ×1
gmail-api ×1
jquery ×1
momentjs ×1
object ×1
onclick ×1
push ×1
radio-button ×1
reload ×1
sql ×1
subdirectory ×1
swiftmailer ×1