我有一个简单的主布局:
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
@yield('style')
</head>
<body>
@include('layouts.frontend.partials.slider')
@yield('javascript')
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
布局.frontend.partials.slider
@section('style')
<link rel="stylesheet" type="text/css" href="mystyle.css">
@append
@section('javascript')
<script></script>
@append
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 1</div>
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 2</div>
<div class="swiper-slide" data-swiper-autoplay="1000">Slide 3</div>
</div>
<div class="swiper-pagination"> </div>
<div class="swiper-button-prev"> </div>
<div class="swiper-button-next"> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
当包含文件中工作正常时,将@section('style')被忽略@section('javascript')...我已将两个文件(主文件和包含文件)减少到最小,并交换了样式和 javascript 的位置,没有任何区别
似乎有效的方法是将位置从身体更改@yield('style')为身体,例如:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
@include('layouts.frontend.partials.slider')
@yield('javascript')
@yield('style')
</body>
Run Code Online (Sandbox Code Playgroud)
也许不允许包含@section在包含文件中?
我想要归档的是拥有多个部分包含及其自己的 css 和 javascript 包含
谢谢
我目前正在将我的 angular 应用程序切换到通用 ssr 应用程序。我的最后一个问题是我的自定义 HttpInterceptor 触发了两次。我正在检查我的 api 调用的 http 响应代码,如果出现错误,则会显示一个弹出窗口。自从我切换到通用后,我两次收到相同的错误弹出窗口。
@Injectable()
export class HttpSetHeaders implements HttpInterceptor {
constructor(
@Inject(PLATFORM_ID) private platformId,
@Inject(LOCAL_STORAGE) private localStorage: any,
private authService: AuthService,
private router: Router,
private notifierService: NotifierService
) { }
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
console.log(isPlatformServer(this.platformId))
......
}
Run Code Online (Sandbox Code Playgroud)
每次 HTTPClient 调用后,我都会看到两次控制台日志输出。
我在 app.module 中导入了 TransferHttpCacheModule,在 app.server.module 中导入了 TransferHttpCacheModule
谢谢马库斯
以前我使用listview和listview的自定义适配器.所有工作都很好,除非我向上和向下滚动数据更改(例如我的if语句我适配器更改listview项目的bg颜色.当我向上和向下滚动颜色改变错误,在第一次加载滚动一切都很好!)
我通过在我的适配器的getView方法中将视图重置为null来解决listview的这个问题.
v = null;
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.friendlv, null);
Run Code Online (Sandbox Code Playgroud)
现在我切换到RecyclerView,我有同样的问题,但我不知道解决这个问题..
谢谢!
有可能在一个集合/ json中获取所有细节(用户,帖子,postimages)?
user-> hasmany(posts)post-> hasmany(postimage)
user:id | 名称
发布:id | user_id | 文本
postimage:id | post_id | imgpath
用户模型:
public function posts() {
return $this->hasMany('App\posts')->orderBy('id', 'ASC');
}
Run Code Online (Sandbox Code Playgroud)
帖子模型:
public function images(){
return $this->hasMany('App\postsimages');
}
Run Code Online (Sandbox Code Playgroud)
从用户获取所有帖子工作正常:
$myposts = users::find(Auth::user()->id)->posts;
Run Code Online (Sandbox Code Playgroud)
我能够从循环内的帖子中获取所有图像
foreach($myposts as $mypost) {
$postimages = $mypost->images;
}
Run Code Online (Sandbox Code Playgroud)
我想要的是获得所有帖子,没有循环的图像,例如
$myposts = users::find(Auth::user()->id)->posts->images
Run Code Online (Sandbox Code Playgroud)
谢谢
错误:这会返回所有用户及其人员:
$me = Auth::user()->with('persons')->get();
Run Code Online (Sandbox Code Playgroud)
正确:这仅返回经过身份验证的用户及其人员
Auth::user()->persons()->get()
Run Code Online (Sandbox Code Playgroud)
模型
public function persons(){
return $this->hasMany('App\Person', 'user_id');
}
Run Code Online (Sandbox Code Playgroud)
区别在哪里?为什么第一行返回所有用户?
谢谢
我要实现的目标:
从jwt令牌受保护的源加载图像,
服务器将图像返回为base64字符串,然后我将该字符串作为背景url加载到图像上
父组件:
<template lang="html">
<myImage v-for="photo in form.photos" :photo="photo" @delphoto="deleteImage"></myImage>
</template>
export default {
components: {
myImage,
},
data(){
return {
form: {
photos: [
{
id: 1,
thumbnail: "logo1.png"
},
{
id: 2,
thumbnail: "logo2.png"
},
{
id: 3,
thumbnail: "logo3.png"
},
{
id: 4,
thumbnail: "logo4.png"
},
]
},
}
},
methods: {
deleteImage(myphoto)
{
this.form.photos.splice(this.form.photos.indexOf(myphoto), 1);
}
}
}
Run Code Online (Sandbox Code Playgroud)
myImage组件
<template>
<div v-if="loaded" class="img">
<img class="albumimg" :style="{ background: img}" :title="title">
<p @click="delimage">delete</p>
</div>
<div v-else …Run Code Online (Sandbox Code Playgroud) 我正在向我的php后端发送post请求但是我无法将数组作为参数传递...或者添加多个具有相同名称的参数,这些参数只会将for循环中的最后一个参数添加到params
此代码有效,但只返回最后一个数字作为参数,而不是两个数字:
protected Map<String, String> getParams() {
ArrayList<String> numbers = new ArrayList<String>();
numbers.add("+431111111111");
numbers.add("+432222222222");
Map<String, String> params = new HashMap<String, String>();
for(String object: numbers){
params.put("friendnr[]", object);
}
return params;
}
Run Code Online (Sandbox Code Playgroud)
我只是想将一个数组,"friendnr"列表传递给我的php后端..
谢谢
有没有办法获得自定义arraylist的独特价值?
public class mystatistic extends BaseActivity {
public String objectid;
public String playerid;
public String playername;
public String enemyid;
public String enemyname;
public String question;
public mystatistik(String objectid, String playerid, String playername, String enemyid, String enemyname, String question) {
this.objectid = objectid;
this.playerid= playerid;
this.playername= playername;
this.enemyid= enemyid;
this.enemyname= enemyname;
this.question= question;
}
Run Code Online (Sandbox Code Playgroud)
添加到arraylist
mystatistic mystatistic2 = new mystatistik(objectid,playerid, playername, enemyid, enemyname,question);
mystatisticslist.add(mystatistic2);
Run Code Online (Sandbox Code Playgroud)
现在我想从我的arraylist"mystatisticslist"中获得所有独特的"敌人".这可能吗?谢谢