我有 2 个查询。尽管第一个更复杂并且提取的数据更多,但执行时间仅为 154 毫秒,而第二个执行时间为 1.76 秒。
首先(执行速度快):
$offers = Offer::select(\DB::raw('tbl_offer.offer_id as sys_id,
tbl_offer.offer_name,
tbl_offer.preview_url,
COALESCE(tbl_offer.is_allow_website_links,
false) as is_allow_website_links,
tbl_offer.is_require_approval,
tbl_relationship.fk_relationship_status_id,
tbl_offer.is_private,
tbl_offer.currency'))
->leftJoin('tbl_relationship', function ($q) use ($affiliateId) {
$q->on('tbl_offer.offer_id', '=', 'tbl_relationship.fk_offer_id')
->where('tbl_relationship.fk_affiliate_id', '=', $affiliateId);})
->whereIn('fk_offer_status_id', [ 18, 19 ])
->where('is_display', 1)
->where('tbl_offer.is_trd_deleted', 0)
->orderBy('offer_name')
->get();
Run Code Online (Sandbox Code Playgroud)
第二个(执行缓慢):
$currencies = Currency::select(\DB::raw('DISTINCT currency_code_from AS currency'))
->where('sys_name', 'openexchangerates')
->orderBy('currency')
->get();
Run Code Online (Sandbox Code Playgroud)
我在模板中有一个div,该模板以#divMessages作为模板引用名称。
<div #divMessages></div>
Run Code Online (Sandbox Code Playgroud)
当发生某些事件时,我想将html标签附加到该div。我尝试了以下方式,但将html标签附加为字符串。
this.divMessages.nativeElement.append('<li>'+data.message+ '</li>');
Run Code Online (Sandbox Code Playgroud)
我当前的方法认为html标签为字符串。我如何附加html标签,以隐藏标签并仅显示数据。(在上述情况下,仅显示列表项,而标签则隐藏)。