<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>朱高的今天前端&quot; - 朱高的今天</title>
	<atom:link href="http://www.zhugao.net/today/tag/front/feed" rel="self" type="application/rss+xml" />
	<link>http://www.zhugao.net</link>
	<description></description>
	<lastBuildDate>Thu, 25 Jun 2026 12:04:53 +0000</lastBuildDate>
	<language>zh-CN</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
		<item>
		<title>第1992天：taro 4 的 .eslintrc.js 问题</title>
		<link>http://www.zhugao.net/today/2026/24875.html</link>
		<comments>http://www.zhugao.net/today/2026/24875.html#comments</comments>
		<pubDate>Mon, 15 Jun 2026 11:24:49 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>
		<category><![CDATA[在路上]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=24875</guid>
		<description><![CDATA[这个问题，困扰了我三天，必须给 taro 团队提个 bug report。 问题描述 Taro 版本：4.2. [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>这个问题，困扰了我三天，必须给 taro 团队提个 <a href="https://github.com/NervJS/taro/issues/19352" target="_blank">bug report</a>。</p>
<blockquote><p>问题描述<br />
Taro 版本：4.2.0<br />
模板：mobx<br />
问题：生成 eslintrc.js 而非 .eslintrc.js</p></blockquote>
<p>临时解决方案：手动把 eslintrc.js 更名为 .eslintrc.js 即可。</p>
<p>p.s.</p>
<p>npm 的时候还发现另一个问题，总是要加 sudo，问了 AI，说是“我的 Node.js 环境权限和配置已经完全乱掉了”，需要修复，以下是修复办法：</p>
<blockquote><p># 备份并删除被污染的 npm 配置<br />
cp ~/.npmrc ~/.npmrc.backup 2&gt;/dev/null<br />
rm -f ~/.npmrc</p>
<p># 创建一个干净的配置（只保留淘宝镜像）<br />
echo &#8220;registry=https://registry.npmmirror.com&#8221; &gt; ~/.npmrc</p>
<p># 删除有权限问题的 cnpm 缓存<br />
sudo rm -rf ~/.npminstall_tarball<br />
sudo rm -rf ~/.cnpmrc</p>
<p># 将全局 npm 目录的所有权还给自己<br />
# 1. 修改目录本身的所有者<br />
sudo chown -R $(whoami) $(npm config get prefix)</p>
<p># 2. 修改目录下关键子文件夹及其内容的所有者<br />
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}</p>
<p># 现在不需要 sudo 了<br />
npm install -g @tarojs/cli@latest</p>
<p># 验证安装成功<br />
taro &#8211;version</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2026/24875.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1990天：taro4 编译性能真强</title>
		<link>http://www.zhugao.net/today/2026/24863.html</link>
		<comments>http://www.zhugao.net/today/2026/24863.html#comments</comments>
		<pubDate>Sat, 13 Jun 2026 14:02:04 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>
		<category><![CDATA[在路上]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=24863</guid>
		<description><![CDATA[h5 用 taro4 写。之前的老项目小程序一直是 taro2，相比之下，肉眼都能感受到 taro4 强劲的编 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>h5 用 taro4 写。之前的老项目小程序一直是 taro2，相比之下，肉眼都能感受到 taro4 强劲的编译速度。</p>
<p>今天跑通了 http 方式调用云函数。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2026/24863.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1750天：wx.chooseMedia 和 wx.previewImage 会触发 onShow</title>
		<link>http://www.zhugao.net/today/2025/23728.html</link>
		<comments>http://www.zhugao.net/today/2025/23728.html#comments</comments>
		<pubDate>Thu, 16 Oct 2025 15:34:14 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=23728</guid>
		<description><![CDATA[微信小程序的 wx.chooseMedia 和 wx.previewImage，不仅会触发 page 的 on [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>微信小程序的 wx.chooseMedia 和 wx.previewImage，不仅会触发 page 的 onShow，还会触发 app 的 onShow。前者还可以理解，后者挺让人意外。</p>
<p>如果有接口调用或其他逻辑放在 app 和 page 的 onShow，要注意处理，避免不必要的调用和执行。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2025/23728.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1699天：云开发的 or 查询，要每个字段建一个索引</title>
		<link>http://www.zhugao.net/today/2025/23467.html</link>
		<comments>http://www.zhugao.net/today/2025/23467.html#comments</comments>
		<pubDate>Tue, 26 Aug 2025 11:21:49 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=23467</guid>
		<description><![CDATA[const whereParams = _.or([{   shopId: 'xxx',   touserMc [&#8230;]]]></description>
				<content:encoded><![CDATA[<blockquote>
<div>
<div>const whereParams = _.or([{</div>
<div>  shopId: 'xxx',</div>
<div>  touserMchShopId: 'xxx',</div>
<div>}, {</div>
<div>  mchShopId: 'xxx',</div>
<div>  touserShopId: 'xxx',</div>
<div>}])</div>
<div></div>
<div>db.collection(&#8216;msg&#8217;)</div>
<div>  .where(whereParams)</div>
<div>  .orderBy(&#8216;createTime&#8217;, &#8216;desc&#8217;)</div>
<div>  .get()</div>
</div>
</blockquote>
<p>对于这样的查询条件，要每个字段建一个索引才能命中，包括 createTime 也要单独建一个索引。</p>
<p>但是 createTime 创建不了索引，问了技术支持的同学，说是系统自带了 createTime 的索引。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2025/23467.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1632天：bindgetphonenumber 和 bindtap 事件冲突</title>
		<link>http://www.zhugao.net/today/2025/23118.html</link>
		<comments>http://www.zhugao.net/today/2025/23118.html#comments</comments>
		<pubDate>Fri, 20 Jun 2025 14:53:13 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=23118</guid>
		<description><![CDATA[小程序的 button，如果同时存在 bindgetphonenumber 和 bindtap，大部分机型两个 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>小程序的 button，如果同时存在 bindgetphonenumber 和 bindtap，大部分机型两个事件都会执行，极少部分机型只会执行 bindtap，不会执行 bindgetphonenumber，导致用户点击按钮时没有拉起手机号授权。</p>
<p>按这个逻辑，button 上的其他 bind 事件也不能和 bindtap 一起使用，例如 bindgetuserinfo、bindcontact 等，应该也会有部分机型不兼容。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2025/23118.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1597天：Cursor真的无敌</title>
		<link>http://www.zhugao.net/today/2025/22936.html</link>
		<comments>http://www.zhugao.net/today/2025/22936.html#comments</comments>
		<pubDate>Fri, 16 May 2025 14:25:36 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=22936</guid>
		<description><![CDATA[公司给前端同学买了 Cursor，初体验很惊艳。今天更是发生一件让我惊叹的事。 我在商品编辑页，想创建一个函数 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>公司给前端同学买了 Cursor，初体验很惊艳。今天更是发生一件让我惊叹的事。</p>
<p>我在商品编辑页，想创建一个函数，名字叫 backToGoodsList。我真的只是这么想的，敲了个回车，这个名字就出来了。那一刻，我觉得自己仿佛是在用意念写代码。</p>
<p>当前文件中并没有 goodsList 这串字符，但是项目中有 goodsList 这个文件。</p>
<p>它应该是把整个项目都当成了上下文。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2025/22936.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1518天：useState 和 useReactive 状态管理区别</title>
		<link>http://www.zhugao.net/today/2025/22574.html</link>
		<comments>http://www.zhugao.net/today/2025/22574.html#comments</comments>
		<pubDate>Wed, 26 Feb 2025 12:06:40 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=22574</guid>
		<description><![CDATA[今天遇到一个 bug，本来用的是 useState，状态变了之后没有重新渲染组件。后面改成 useReacti [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>今天遇到一个 bug，本来用的是 useState，状态变了之后没有重新渲染组件。后面改成 useReactive 就好了。查一下有意外收获。</p>
<p><a href="http://www.zhugao.net/wp-content/uploads/2025/02/20250226-1.png" rel="lightbox[22574]"><img class="alignnone size-thumbnail wp-image-22575" alt="20250226-1" src="http://www.zhugao.net/wp-content/uploads/2025/02/20250226-1-300x88.png" width="300" height="88" /></a></p>
<p><a href="http://www.zhugao.net/wp-content/uploads/2025/02/20250226-2.png" rel="lightbox[22574]"><img class="alignnone size-thumbnail wp-image-22576" alt="20250226-2" src="http://www.zhugao.net/wp-content/uploads/2025/02/20250226-2-300x283.png" width="300" height="283" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2025/22574.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1379天：抖音云 nodejs 模板，由 ts 改成 js，以及云调用域名问题</title>
		<link>http://www.zhugao.net/today/2024/21936.html</link>
		<comments>http://www.zhugao.net/today/2024/21936.html#comments</comments>
		<pubDate>Thu, 10 Oct 2024 14:55:29 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=21936</guid>
		<description><![CDATA[抖音云提供的 nodejs 模板是 typescript 的。刚开始没深入写，就调试一下接口，没觉得 ts 和 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>抖音云提供的 <a href="https://developer.open-douyin.com/docs/resource/zh-CN/developer/tools/cloud/quick-start/template" target="_blank">nodejs 模板</a>是 typescript 的。刚开始没深入写，就调试一下接口，没觉得 ts 和 js 有啥太大区别，没想到定义个变量都成了老大难的事情。</p>
<p>还是老老实实改成 js。但是又遇到 webpack 打包 node 项目的问题，一时半会没太多时间处理。想想看后端打包个啥？就这几个包。</p>
<p>动一下手术：</p>
<p>1、删除 tsconfig.json。抖音云 node 模板自带的 Dockerfile，会判断是否有 tsconfig.json，有的话就会执行 npm run build。</p>
<p>2、修改 package.json</p>
<ul>
<li>删除 ts 相关的包</li>
<li>删除 scripts 下的 &#8220;build&#8221;: &#8220;tsc&#8221;</li>
<li>启动命令 &#8220;node dist/server.js&#8221; 改成 &#8220;node src/server.js&#8221;</li>
</ul>
<p>3、如果要使用 es 规范，可以在 package.json 里添加 &#8220;type&#8221;: &#8220;module&#8221;，或者 .js 文件后缀改成 .mjs</p>
<p>4、导入模块时可能要用完整的 js 文件路径，例如：import { test } from &#8216;./test.js&#8217;</p>
<p>5、另外需要注意，抖音云调用的域名有自己专属的域名，而且目前只支持 http 协议，可以看<a href="https://developer.open-douyin.com/docs/resource/zh-CN/developer/tools/cloud/develop-guide/cloud-call" target="_blank">云调用官方文档</a>，例如​ ​developer.toutiao.com ​对应的云调用域名是 ​developer-toutiao-com.openapi.dyc.ivolces.com，我在这上面坑了好长时间，后面补看文档才发现。如果没按这个来，请求外部接口时会报错：</p>
<blockquote><p>FetchError: request to failed, reason: unable to verify the first certificate at ClientRequest</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2024/21936.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1362天：Taro 对抖音小程序支持不太好</title>
		<link>http://www.zhugao.net/today/2024/21855.html</link>
		<comments>http://www.zhugao.net/today/2024/21855.html#comments</comments>
		<pubDate>Mon, 23 Sep 2024 14:50:27 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=21855</guid>
		<description><![CDATA[这两天在折腾抖音小程序的交易系统组件，用的是 Taro，一不小心就掉坑里，只能用原生模块的方式来处理。 如果用 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>这两天在折腾抖音小程序的<a href="https://developer.open-douyin.com/docs/resource/zh-CN/mini-app/develop/component/industry/trading-system/guide" target="_blank">交易系统组件</a>，用的是 Taro，一不小心就掉坑里，只能用<a href="https://taro-docs.jd.com/docs/hybrid#1-%E5%9C%A8-app-%E6%88%96%E9%A1%B5%E9%9D%A2%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%AD%E9%85%8D%E7%BD%AE-usingcomponents-%E5%B1%9E%E6%80%A7" target="_blank">原生模块</a>的方式来处理。</p>
<p>如果用原生模块能解决也就好了，但是仍然解决不了，就连抖音官方提供的 <a href="https://developer.open-douyin.com/search-page?keyword=taro-demo&amp;secondType=all&amp;type=4" target="_blank">taro-demo</a> 也运行不起来。</p>
<p>还是老老实实用原生来写靠谱。</p>
<p>实践证明，Taro 对微信小程序支持很好，但是对抖音小程序支持一般。</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2024/21855.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1304天：vue3 + vite 项目部署在非根路径</title>
		<link>http://www.zhugao.net/today/2024/21582.html</link>
		<comments>http://www.zhugao.net/today/2024/21582.html#comments</comments>
		<pubDate>Sat, 27 Jul 2024 14:11:59 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=21582</guid>
		<description><![CDATA[项目通常都是部署在根目录，但是如果要部署在非根目录，例如 https://www.aaa.com/xxx/ 要 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>项目通常都是部署在根目录，但是如果要部署在非根目录，例如 https://www.aaa.com/xxx/</p>
<p>要改三个地方，把目录名带上。</p>
<p>vite.config.js</p>
<blockquote><p>export default defineConfig({<br />
base: &#8216;/xxx/&#8217;,<br />
&#8230;<br />
})</p></blockquote>
<p>router 文件</p>
<blockquote><p>const router = createRouter({<br />
history: createWebHistory(&#8216;/xxx/&#8217;),<br />
&#8230;<br />
})</p></blockquote>
<p>nginx 加一段配置（解决页面刷新报错的问题）</p>
<p>注意：root 路径改成自己服务器的真实路径</p>
<blockquote><p>location ^~ /xxx/ {<br />
root /opt/app/nginx;<br />
index index.html index.htm;<br />
try_files $uri Suri/ /xxx/index.html;<br />
break;<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2024/21582.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
