我有这样的导航组件:
<template>
<nav class="navbar navbar-default navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="">Website Builder</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li>
<a href="#" @click.native="currentView='create'">Create</a>
</li>
<li>
<a href="#" @click.native="currentView='how'">How</a>
</li>
<li>
<a href="#" @click.native="currentView='about'">About</a>
</li>
<li>
<a href="#" @click.native="currentView='youtube'">Videos</a>
</li>
</ul>
</div>
</div>
</nav>
</template>
Run Code Online (Sandbox Code Playgroud)
和我的js:
Vue.component('navigation', Navigation)
Vue.component('create', Create)
Vue.component('how', How)
Vue.component('about', About)
Vue.component('youtube', Youtube)
new Vue({
el: '#app',
data: {
currentView: 'create'
}
Run Code Online (Sandbox Code Playgroud)
和HTML:
<div …Run Code Online (Sandbox Code Playgroud) 当发生某些事情时,我将 body 设置background-color为 gray 并减少opacity。然而,这显然也会改变按钮的不透明度。
我想要实现的是当动作发生时,改变除按钮之外的所有内容的不透明度。
var highlight = $('#' + scroll).closest('div').find('button');
$('body').css('opacity', '0.2');
$('body').css('background-color', 'grey');
$(highlight).css('background-color', '#FDFF47');
$(highlight).css('opacity', '1');
Run Code Online (Sandbox Code Playgroud)
那怎么办呢?
我已经通过 npm 安装了 jquery。
包.json:
"jquery": "^3.2.1",
Run Code Online (Sandbox Code Playgroud)
在我的 JS 中,我这样做:
import $ from 'jquery';
Run Code Online (Sandbox Code Playgroud)
但是它仍然说 $ 在我的浏览器中未定义,这是为什么?
我有这样的模型:
Entity - entities table
Address - address table
User - users table
Geoloc - geoloc table
UserEntity - entity_user table
Run Code Online (Sandbox Code Playgroud)
现在 Entity 可以有一个地址和一个 geoloc,但它可以有多个用户,这就是 UserEntity 的用途。
所以我需要做一个模式,工厂会像这样创建它:
用户>实体>地址>Geoloc>UserEntity
因此,当创建用户时,它还会创建实体、地址和 geoloc,将实体 id 与地址关联,将 geoloc id 与实体关联,并将 user_id 和 entity_id 插入到用户实体中。
这是我目前的设置:
地址工厂:
$factory->define(App\Address::class, function (Faker $faker) {
return [
'building_name' => $faker->company,
'address' => $faker->streetAddress,
'town' => $faker->city,
'postcode' => $faker->postcode,
'telephone' => $faker->phoneNumber,
'private' => $faker->boolean($chanceOfGettingTrue = 50),
'entity_id' => function () {
return factory(App\Entity::class)->create()->id;
}
];
});
Run Code Online (Sandbox Code Playgroud)
实体工厂: …
我有一个这样的功能:
public function entity($entity_id, Request $request)
{
$expiresAt = Carbon::now()->addMinutes(10);
$entity = Cache::remember('entities', $expiresAt, function () {
return Entity::where('id', $entity_id)
->with('address')
->with('_geoloc')
->first();
});
Run Code Online (Sandbox Code Playgroud)
然而,这会返回一个错误,说 $entity_id 未定义,但是当我在 $expiresAt 之后执行 dd($entity_id) 时,它被定义为我取回 id,如果需要,id 来自 url。
我想实现一个人们可以改变他们位置的功能.为此我想使用google places api.现在我想要的是一个搜索框,当有人输入一个城镇/地方时,它将搜索谷歌的地方并得出结果.一旦选择了位置,它将给我拉特和那个地方.没有地图可以吗?
谢谢
laravel ×2
laravel-5 ×2
css ×1
faker ×1
google-maps ×1
html ×1
javascript ×1
jquery ×1
laravel-5.5 ×1
node.js ×1
npm ×1
php ×1
vue.js ×1
vuejs2 ×1
webpack ×1