<?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>Mon, 11 May 2026 06:33:06 +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>第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>
		<item>
		<title>第1293天：开发环境和生产环境复杂接口场景</title>
		<link>http://www.zhugao.net/today/2024/21536.html</link>
		<comments>http://www.zhugao.net/today/2024/21536.html#comments</comments>
		<pubDate>Tue, 16 Jul 2024 14:47:00 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=21536</guid>
		<description><![CDATA[由于历史原因，接口有点混乱，有的是开发环境和生产环境共用，有的有区分，被逼出了这么个解决方案，看上去不会出错了 [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>由于历史原因，接口有点混乱，有的是开发环境和生产环境共用，有的有区分，被逼出了这么个解决方案，看上去不会出错了。</p>
<blockquote><p>// 环境判断<br />
const isProdEnv = xxxxxxx</p>
<p>// 域名列表<br />
const server = &#8216;https://server.xxx.chat/&#8217;<br />
const test = &#8216;https://test.xxx.chat/&#8217;<br />
const www = &#8216;https://www.xxx.chat/&#8217;<br />
const wx = &#8216;https://wx.xxx.chat/&#8217;<br />
const api = &#8216;https://api.xxx.chat/&#8217;</p>
<p>export const baseUrls = {<br />
basic: isProdEnv ? server : test,<br />
login: isProdEnv ? www : www,<br />
scene: isProdEnv ? www : wx,<br />
message: isProdEnv ? server : server,<br />
redirect: isProdEnv ? www : test,<br />
pay: isProdEnv ? api : api,<br />
socket: isProdEnv ? www : www,<br />
}</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2024/21536.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>第1292天：前端编码约定</title>
		<link>http://www.zhugao.net/today/2024/21533.html</link>
		<comments>http://www.zhugao.net/today/2024/21533.html#comments</comments>
		<pubDate>Mon, 15 Jul 2024 14:25:54 +0000</pubDate>
		<dc:creator>zhugao</dc:creator>
				<category><![CDATA[今天]]></category>
		<category><![CDATA[前端]]></category>

		<guid isPermaLink="false">http://www.zhugao.net/?p=21533</guid>
		<description><![CDATA[简单整理了一份《前端编码约定》，这是其中一条： 组件思想 参考：https://cn.vuejs.org/gu [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>简单整理了一份《前端编码约定》，这是其中一条：</p>
<blockquote><p>组件思想<br />
参考：<a href="https://cn.vuejs.org/guide/essentials/component-basics.html" target="_blank">https://cn.vuejs.org/guide/essentials/component-basics.html</a></p>
<p>页面入口文件是一个集合组件的文件，不要直接在入口文件写业务代码。</p>
<p>即：进入一个页面，首先看到的是一棵树，然后才能看清它的树枝 (component) 和树叶 (children)，而不是一开始就掉进树里，看不清方向。</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.zhugao.net/today/2024/21533.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
