鍍金池/ 問(wèn)答/ HTML問(wèn)答
還吻 回答

按理說(shuō)你的代碼,正常運(yùn)行是會(huì)監(jiān)聽(tīng)8090端口。

但是你說(shuō)沒(méi)有監(jiān)聽(tīng)這個(gè)8090端口,那么很大的可能性是你應(yīng)用的其他地方有編程式的dev-server。

編程式的優(yōu)先級(jí)大于配置式
冷溫柔 回答
紙上得來(lái)終覺(jué)淺 絕知此事要躬行

好好的做幾個(gè)項(xiàng)目吧。做的多了,記得也就牢了。

神曲 回答

上文中所寫(xiě)的代碼極其危險(xiǎn)

建議對(duì)于這種嵌有HTML的內(nèi)容 通過(guò)使用模板文件進(jìn)行存儲(chǔ),使用占位符的形式來(lái)對(duì)內(nèi)容進(jìn)行替換。

建議方案

  • email.template
<html>
    <head>
        {$phpmailer_css_style}
    </head>

    <body>
    <div class="edm-layout">
      <img src="{$host_url}images/logo.png">
      <div class="line"></div>
    </div>

    <div class="edm-content">
      <div class="edm-hithere">
        嗨,{$user_name} <br>XXX {$prod_total}XXXXX<br>XXXXXX{$this_total} XXX
      </div>
      
        <div class="edm-products">
            {$row_distinct}
        </div>
      </div>
    </div>
  </body>
</html>
  • EmailTemplate.php

<?php
$php_version = version_compare(phpversion(), '7');
/**
 * 必須php 7
 */
if ($php_version === -1) {
    die('Need a high version of php 7.1.*');
}
/**
 * EmailTemplate
 */
class EmailTemplate
{
    /**
     * @param string $template_path 模板路徑
     * @param array $args 變量組
     * @return string 渲染后的
     * @throws Exception
     */
    public static function render(string $template_path, array $args): string
    {
        if (!file_exists($template_path)) {
            throw new Exception("Not found template fiel.", 1);

        }
        $template = file_get_contents($template_path);
        $result = preg_replace_callback('!\{\$(\w+)\}!', function ($matches) use ($args) {
            $arg = $matches[1];
            return $args[$arg] ?? '';
        }, $template);
        return $result;
    }
}
  • demo.php
$body = EmailTemplate::render(
    'email.template',
    [
        'host_url' => 'http://xxx',
        'phpmailer_css_style' => 'empty',
        'user_name' => '張三',
        'prod_total' => '100.00',
        'this_total' => '10000.00',
        'row_distinct' => 'empty',
    ]
);

這樣就實(shí)現(xiàn)了一個(gè)簡(jiǎn)單的模板替換。

這樣?

<script>
    $('table tr').click(function () {
        $(this).find('td').addClass('redcolor');
        $(this).siblings().find('td').removeClass('redcolor');
    })
</script>
<style>
    .redcolor{
        color: red
    }
</style>
故人嘆 回答

就是搞一個(gè)方法遍歷數(shù)組,然后如果有children就再用children調(diào)用一次,所有出現(xiàn)過(guò)的數(shù)據(jù)都push到一個(gè)地方,最后輸出這個(gè)結(jié)果。

str="ADMIN,27cfb184cba7497f8bc34af8d228b988,712803a9c33e4110961ed40a113db874,0747714bf99b4cf2919ee73eb4ac7662".split(',');

((_list)=>{
    var arr = [];
    var _fun = (__arr)=>{
        __arr.forEach(v=>{
            if(!!~str.indexOf(v.id)) arr.push({label:v.text,value:v.id})
            if(v.children.length) _fun(v.children)
        });
    }
    _fun(_list);
    return arr
})([
{
"id": "ADMIN",
"checked": false,
"text": "數(shù)據(jù)中心",
"leaf": true,
"priority": -1,
"children": []},{"id": "27cfb184cba7497f8bc34af8d228b988",
"checked": false,
"text": "貸后管理",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "898f63e4fc144dc19abd973a403645e6",
    "checked": false,
    "text": "法律公司",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "aa5f74be66f04e62bbcea34717133624",
    "checked": false,
    "text": "墊息部",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "bada5b2760ab4e879f9d7200536917b6",
    "checked": false,
    "text": "催討部",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "cb781db8f4e84ad7b0570eca9960a954",
    "checked": false,
    "text": "合同管理部",
    "leaf": true,
    "priority": 1,
    "children": []}]},{"id": "f3cdf3e6949b49c19b624eee6a08f0e8",
"checked": false,
"text": "業(yè)務(wù)部",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "0747714bf99b4cf2919ee73eb4ac7662",
    "checked": false,
    "text": "業(yè)務(wù)二部",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "712803a9c33e4110961ed40a113db874",
    "checked": false,
    "text": "業(yè)務(wù)一部",
    "leaf": true,
    "priority": 123,
    "children": []
  }
]}])
萌面人 回答

1.方法定義寫(xiě)的有問(wèn)題 function(){} -- 少了括號(hào)
2.一般不直接這么做,更改樣式什么的一般通過(guò)移除or添加class進(jìn)行

入她眼 回答

你這個(gè)會(huì)處理所有請(qǐng)求,但是 option 請(qǐng)求是不能設(shè)置 Content-Type 頭部的. 你得為 option 請(qǐng)求單獨(dú)的設(shè)置 cors 頭, 然后為正常請(qǐng)求設(shè)置 Content-Type 頭返回響應(yīng).

墨沫 回答

個(gè)人覺(jué)得應(yīng)該是路由配置那里的問(wèn)題,記得之前翻vue文檔的時(shí)候,路由配置有兩種模式,一種是默認(rèn)的hash模式,另一種就是mode:'history'模式,這個(gè)需要后臺(tái)配置支持,沒(méi)見(jiàn)過(guò)base這種寫(xiě)法。

兔寶寶 回答

用方法3,同時(shí)把操作抽成函數(shù),cwr和cdm都調(diào)用一次

墨小羽 回答

后端簡(jiǎn)化下接口,就做成一個(gè)接口

失魂人 回答

你構(gòu)造的子類完全沒(méi)有用到啊……

其實(shí)你的想法是用一個(gè)“子類”創(chuàng)建一個(gè)模塊,模塊中的模板一部分由這個(gè)子類直接處理,一部分由父類處理。但你其實(shí)走錯(cuò)路了,你應(yīng)該用組件解決問(wèn)題?!白宇悺笔窃O(shè)計(jì)用在別的場(chǎng)景中的。

懶洋洋 回答

用了 transition 的話,在切換路由的時(shí)候,兩個(gè)頁(yè)面會(huì)同時(shí)存在于文檔中,所以出現(xiàn)你說(shuō)的現(xiàn)象。
讓他們層疊起來(lái)就好了唄。

.fade-enter-active, .fade-leave-active {
  transition: opacity .5s;
  
  position: absolute;
  top: 0;
  left: 0;
}
苦妄 回答

不卸載小程序的話,下一次點(diǎn)擊不會(huì)彈出,可以使用wx.openSetting來(lái)設(shè)置

近義詞 回答

官網(wǎng)說(shuō)的webpack.base.conf.js應(yīng)該這么干呀:

      {
        test: /\.js$/,
        loader: 'babel-loader',
-       include: [resolve('src'), resolve('test')]
+       include: [resolve('src'), resolve('test'), resolve('node_modules/vue-awesome')]
      }

不太懂你的做法.

我以為 回答

raw:文件內(nèi)容。
blame:按行顯示最新提交的信息。
history:文件的歷史記錄。