<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Joie on Medium]]></title>
        <description><![CDATA[Stories by Joie on Medium]]></description>
        <link>https://medium.com/@aileen60222?source=rss-58f9ecdcf240------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*-aBzjkeaHcjDv358Tz4grQ.jpeg</url>
            <title>Stories by Joie on Medium</title>
            <link>https://medium.com/@aileen60222?source=rss-58f9ecdcf240------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 00:27:24 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aileen60222/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[申請第三方登入憑證- Facebook]]></title>
            <link>https://medium.com/@aileen60222/%E7%94%B3%E8%AB%8B%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%85%A5%E6%86%91%E8%AD%89-facebook-c0051dd7c686?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0051dd7c686</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 08:45:30 GMT</pubDate>
            <atom:updated>2020-07-03T08:45:30.014Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><p>➡️ <a href="https://developers.facebook.com/apps/">Facebook for Developers🔗</a></p><h4>1️⃣ 新增應用程式</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yXtdAEIgjv2UTiSRc0pUrg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rY5B7o64Dcfn_KNBJX6a_A.png" /></figure><h4>2️⃣ 輸入想要用的專案名稱</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lJsj48iA7C-SereKcc4nmw.png" /></figure><h4>3️⃣ 完成後就可以拿到憑證的編號及密碼了 👌</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5cjUJFK1HvKmt_SJFHwaA.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0051dd7c686" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[申請第三方登入憑證- Google]]></title>
            <link>https://medium.com/@aileen60222/%E7%94%B3%E8%AB%8B%E7%AC%AC%E4%B8%89%E6%96%B9%E7%99%BB%E5%85%A5%E6%86%91%E8%AD%89-google-4387325883ca?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/4387325883ca</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 08:34:33 GMT</pubDate>
            <atom:updated>2020-07-03T08:34:33.494Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><p>➡️ <a href="https://console.cloud.google.com/">Google Cloud Platform🔗</a></p><h4>1️⃣ 進入後先新增自己要使用的專案</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DK9FZPhltuqA5coBgVwxTg.png" /></figure><h4>2️⃣ 接著到 API 和服務 &gt; 憑證</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WIiZIaK3FI2oJgPx_kkPvQ.png" /></figure><h4>3️⃣ 首先設定同意畫面</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZcxQmn5fj_Va7hk0NHnXJA.png" /></figure><p>依照需求選擇類型及填入相關資料 ⬇️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iclv7hX2v-rhiu7cEdaqjA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2qABYFhpOr0RN5yMZGnSYg.png" /></figure><h4>4️⃣ 接著建立憑證，選擇 OAuth 用戶端 ID</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AjFbAPc0TzoUOq4IIPhTkw.png" /></figure><p>依照需求選擇類型及填入相關資料 ⬇️<br>(網站只是在本機測試的時候可以先填 localhost 的路徑)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xfMjmhw15RF8NhX1gFBRng.png" /></figure><p>已授權的重新導向 URI 則填導向 Google 登入的路徑 ⬇️</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FEHhDUQVbbxFtmE_goJiw.png" /></figure><p>完成後就可以得到對憑證 ID 及密碼，填入專案中對應的地方就可使用了 🙋</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Ncvmfgx-LCKMCNgX0dd3A.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4387325883ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rails 專案中安裝 Factory Bot]]></title>
            <link>https://medium.com/@aileen60222/rails-%E5%B0%88%E6%A1%88%E4%B8%AD%E5%AE%89%E8%A3%9D-factory-bot-e6a9ce79ad70?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6a9ce79ad70</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 09:04:32 GMT</pubDate>
            <atom:updated>2020-07-02T09:04:32.121Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><p>1️⃣ 在 Gemfile 中新增 Factory Bot 及對應版本號，完成後在終端機執行 bundle install</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/849/1*dkmOBM0m0hZhYXRpX_Rkiw.png" /></figure><p>2️⃣ 在 spec 目錄下建立 support 資料夾，並新增 factory_bot.rb 檔案</p><pre>(spec/support/factory_bot.rb)</pre><pre>RSpec.configure do |config|<br>  config.include FactoryBot::Syntax::Methods<br>end</pre><p>3️⃣ 在 spec 目錄下 rails_helper.rb 中 require factory_bot</p><pre>(spec/rails_helper.rb)</pre><pre>require ‘support/factory_bot’</pre><p>❗ Tips: 因為有引用到 RSpec ，所以在 rails_helper.rb 中需要在 rspec/rails 之後 require</p><p>❗ Tips: 有這個設定檔在之後寫測試的時候就可以省略建立資料的語法</p><p>原本 👉 task = FactoryBot.create(:task)</p><p>省略後 👉 task = create(:task)</p><p>參考資料:</p><p><a href="https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md#defining-factories">Factory Bot 官方文件 🔗</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6a9ce79ad70" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[將 Rails 專案部署到 Heroku]]></title>
            <link>https://medium.com/@aileen60222/%E5%B0%87-rails-%E5%B0%88%E6%A1%88%E9%83%A8%E7%BD%B2%E5%88%B0-heroku-1d748f4a2625?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/1d748f4a2625</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 07:31:08 GMT</pubDate>
            <atom:updated>2020-07-06T09:16:56.893Z</atom:updated>
            <content:encoded><![CDATA[<h3>將 Rails 專案佈署至 Heroku 步驟</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><p>文章內預設的環境如下：</p><ul><li>Rails 版本: 6</li><li>版控: Git</li><li>資料庫: PostgresSQL</li></ul><p>1️⃣ 在 <a href="https://dashboard.heroku.com/">Heroku🔗</a> 新增 App</p><p>新增 App 後到 Resources 建立資料庫，</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_LO8Ehk26fPsi6WTwYtkwA.png" /><figcaption>(1) 按下 Find more add-ons</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XAk2QGAKDjvNG6Q3gDSBzQ.png" /><figcaption>(2) 選擇 Heroku Postgres</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xxvavMPr2SnbopmglLwjdA.png" /><figcaption>(3) 選擇完就會為你建立資料庫</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nBZhRQCggvykHZNLLjS8mg.png" /><figcaption>並且會自動幫你把 DB URL 的資訊新增到 Setting &gt; Config Vars 裡面</figcaption></figure><p>2️⃣ 切換到自己的專案目錄下，並切換 master 分支，依序執行如下指令</p><blockquote>登入 Heroku</blockquote><pre>$ heroku login</pre><blockquote>跟在 Heroku 新增的專案連結</blockquote><pre>$ heroku git:remote -a joey-heroku-app (←自己的專案名稱)</pre><blockquote>將檔案 push 到 Heroku</blockquote><pre>$ git push heroku master</pre><blockquote>在 Heroku 上建立資料表</blockquote><pre>$ heroku run rake db:migrate</pre><blockquote>啟動 Web Dyno 的服務</blockquote><pre>$ heroku ps:scale web=1</pre><p>🏃 接著就可以去看看專案是否成功部屬了 🏃</p><p>❗ : 如果在執行中遇到問題可以去 View logs 查看錯誤訊息</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YUIgCLMQJWudpXLOI0JJ1g.png" /></figure><p>參考資料:</p><ul><li><a href="https://devcenter.heroku.com/articles/getting-started-with-rails6#deploy-your-application-to-heroku">Getting Started on Heroku with Rails 6.x</a></li><li><a href="https://www.heroku.com/dynos">Heroku Dynos | Heroku</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1d748f4a2625" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RSpec 安裝]]></title>
            <link>https://medium.com/@aileen60222/rspec-%E5%AE%89%E8%A3%9D-b593b5ea19a2?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/b593b5ea19a2</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Mon, 22 Jun 2020 16:21:23 GMT</pubDate>
            <atom:updated>2020-06-22T16:21:23.803Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><p>到 <a href="https://rubygems.org/">Gem 網站</a>搜尋 RSepc 並複製最新的 Gem file 版本</p><pre>gem &#39;rspec-rails&#39;, &#39;~&gt; 4.0&#39;, &#39;&gt;= 4.0.1&#39;</pre><p>貼到自己的 Gemfile 中 development, test 的 group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/843/1*L1B_Yoxf19QALNvZ9oYoKA.png" /></figure><p>回到自己的終端機執行：</p><pre>$ bundle install</pre><p>接著為你的專案裝 RSpec，執行以下：</p><pre>$ rails g rspec:install</pre><p>執行成功就會為你新增以下的檔案及資料夾：</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*PLbXynk_hOkbfHvZrX7F_g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b593b5ea19a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flowdock 無法連到 GitHub 組織中的Repository]]></title>
            <link>https://medium.com/@aileen60222/flowdock-%E7%84%A1%E6%B3%95%E9%80%A3%E5%88%B0-github-%E7%B5%84%E7%B9%94%E4%B8%AD%E7%9A%84repository-215237817f2f?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/215237817f2f</guid>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Sat, 09 May 2020 11:33:48 GMT</pubDate>
            <atom:updated>2020-05-09T11:36:50.820Z</atom:updated>
            <content:encoded><![CDATA[<h3>Flowdock 連結 GitHub 組織中的Repository</h3><p>在 Flowdock 的群組的 Inbox 中想要連結專題組織中的 Repository，但是授權 GitHub 帳號之後卻無法找到組織中的 Repository ，只看的到自己的 Repository ❓</p><p>1️⃣ 進到想要連結的 GitHub 組織</p><p>2️⃣ Settings (設定頁面 )</p><p>3️⃣ Third-party access (第三方權限)</p><p>接下來會看到裡面有 Flowdock 授權可能被拒絕了，按下 Grant 按鈕之後就可以同意 Flowdock 存取這個 GitHub 組織的Repository了</p><p>設定成功如下 👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dHPI08J6SvORrnY-OnIOYA.png" /></figure><p>參考資料: <a href="https://help.github.com/en/github/setting-up-and-managing-organizations-and-teams/approving-oauth-apps-for-your-organization">Approving OAuth Apps for your organization🔗</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=215237817f2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[[Gem] figaro 安裝]]></title>
            <link>https://medium.com/@aileen60222/gem-figaro-%E5%AE%89%E8%A3%9D-417fd6acc475?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/417fd6acc475</guid>
            <category><![CDATA[gem]]></category>
            <category><![CDATA[ruby]]></category>
            <category><![CDATA[rails]]></category>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Sat, 09 May 2020 05:05:12 GMT</pubDate>
            <atom:updated>2020-05-09T05:11:20.731Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><h4>❗<a href="https://github.com/laserlemon/figaro">官方文件GitHub🔗</a> ：官方用法是可能改變的，所以務必跟官方文件配著看唷❗</h4><h4>🐱‍👤 首先到 <a href="https://rubygems.org/">Gem🔗</a> 搜尋 figaro</h4><ul><li>找到最新版本且下載次數很高的，將版本號一起複製到你的 gemfile</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/479/1*91DmIjIKmuvUAIdYbZplVA.png" /><figcaption>📝版本號一起複製是為了之後別人或是自己 bundle install 的時候可以安裝差不多的版本，而不會因為之後裝到新的版本卻因版本落差有 bug。</figcaption></figure><ul><li>接著在你的終端機專案目錄下執行 bundle install &amp; bundle exec figaro install</li></ul><h4>🐱‍👤 安裝後</h4><ul><li>安裝完成後在你的 config 目錄下就會有一個 application.yml 檔案，同時如果你有使用 git 他也會被新增到 .gitignore 檔案裡面，因為牠就是為了讓我們把一些重要的帳號密碼及金鑰儲存在這個檔案，但不被 git 追蹤上傳。</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*JodeFc-5VdojYEXieppAkA.png" /></figure><ul><li>接著把重要的金鑰填入</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/834/1*bM9m1HI1IRwLvsfE-TqCYg.png" /></figure><ul><li>接著你可以設定一個 sample 檔案，讓他可以被 git 追蹤，裡面放所有的會用到的變數名稱，讓其他下載或共用這個專案人也可以方便補上所有這個專案需要的金鑰或帳密等等~</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/471/1*VgoyJ_n92dVXnXCiE5wCng.png" /></figure><ul><li>使用只需要在你設定的變數外面加上 ENV[&#39;&#39;] 就可以了</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*_pWx0zMS8SrYIAV3vO24bQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=417fd6acc475" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[用 Stimulus 及 Ajax 做購物車數量即時更新 (Part.2)]]></title>
            <link>https://medium.com/@aileen60222/%E7%94%A8-stimulus-%E5%8F%8A-ajax-%E5%81%9A%E8%B3%BC%E7%89%A9%E8%BB%8A%E6%95%B8%E9%87%8F%E5%8D%B3%E6%99%82%E6%9B%B4%E6%96%B0-part-2-9ebfd1150929?source=rss-58f9ecdcf240------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ebfd1150929</guid>
            <category><![CDATA[astro-camp]]></category>
            <dc:creator><![CDATA[Joie]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 09:24:13 GMT</pubDate>
            <atom:updated>2020-04-27T15:18:28.366Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-Wc1HSvOfxFtnjBqqPICA.jpeg" /></figure><h4>( 4 ) 來寫寫你想要執行的 action</h4><h4>❓ Ajax 的東西到底要怎麼填 ❓</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*XbPW2nAWGR27SYZvzzLuKQ.png" /></figure><ol><li>url ：就是平常在 Rails 的 form 設定 submit 後要去的路徑</li><li>type： 就是平常 Rails 的 form 設定的 method</li><li>success: resp =&gt; { } <br>這裡代表的是 ajax 把資料成功依照路徑打給 Rails 的 Action 後我得到的 resp (回傳值)及要做的事情( 在 { } 裡面更新購物車)</li><li>error: err =&gt; { } <br>這裡是 ajax 把資料成功依照路徑打給 Rails 的Action 後卻失敗，我得到的 err (回傳值，錯誤訊息)及要做的事情( 在 { } 告知使用者加入失敗)</li></ol><p>所以如果我們不知道 1️⃣ , 2️⃣ 要打甚麼就可以去這裡找找 👇</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4ZqDm_F3IGX3Xru6k1Nk6g.png" /></figure><p>由此可見我們想加入購物車要走的路徑是items/:item_id/comments ，使用的 method 是 POST</p><h4>⬇️ 接著我們來煩惱 :item_id 要從哪裡取得比較好 ⬇️</h4><p>❌ 我直接開一個隱藏欄位<br>&lt;input type=”hidden” id=”item_id” value=”&lt;%= item.id %&gt;”&gt; <br>但是這樣的話每個餐點的 input id 都會是”item_id”，大家的元素 id 就都重複了會有問題，永遠只抓的到第一個餐點的 Value</p><p>👌 使用 Stimulus 提供的抓特定元素的方法，<a href="https://stimulusjs.org/reference/targets">詳細看這裡 🔗</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*ILtHVjF3xwIILYAICpIj7A.png" /><figcaption>Tips: 記得要把想給 controller 風 JS 接到的值包在 data-controller=”item” 的區域裡面才可以被接到</figcaption></figure><p>想要讓 JS controller 抓到某個欄位的值就需要在那個欄位加上<br>data-target=”[controller 風 JS 檔名].[他在 JS controller 裡被抓到的名稱]”</p><p>設定好 HTML 的部分我們再回去 controller 風 JS 接剛剛設定好的值，<a href="https://stimulusjs.org/reference/targets">詳細看這裡 🔗</a></p><ul><li>接的方法是宣告 static targets = [&quot;item_id&quot; ] <br>承HTML: static targets = [&quot;他在 JS controller 裡被抓到的名稱&quot;]</li><li>想要取該元素的值的話這樣用 this.item_idTarget.value <br>承HTML: this.[&quot;他在 JS controller 裡被抓到的名稱&quot;]Target.value</li><li>將抓到的餐點 item_id 投給變數，再串到 Ajax 的 url 裡面就可以成功對我們按的餐點用加入購物車功能惹</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*68YLW3rEtXIjgLKcnIBIwQ.png" /></figure><h3>( 5 ) 回頭去 Rails 的 controller 修改一下</h3><ul><li>其實只差在原本是重新導向餐點列表頁，但我們為了不換頁所以直接回傳 JSON 字串給 controller 風 JS ，<strong>讓 JS 直接幫我們更新購物車數量</strong>，而不透過 Rails 的 controller 幫我們重新導向頁面更新購物車數量</li><li>使用 render 是因為 render 會直接幫我們把想要回傳的資料渲染在當前頁面，如果用 redirect_to 就會有重新導向的意味，就不能達到想要的效果惹</li><li>還記得 Ajax 寫的時後有個 success: resp =&gt; {} 的地方嗎，我們這裡完成更新後傳送的結果 ( JSON 字串) 就會給那個 resp 接到，所以我們就可以在這裡傳送購物車的總數量</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/453/1*yqsb5-NyEnxWRX_2O7tAcQ.png" /></figure><h3>( 6 ) 去 controller 風 JS 裡面更新購物車數量</h3><ul><li>接著我們要想辦法把這個值拿去更新購物車數量，我比較懶所以直接給購物車的數量包一個 span ，送他一個 id ，這樣我就可以直接用 JS 把他選起來，然後把內容換成我新的購物車數量惹</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/534/1*o2eUVl4hToxEJoqSxBDRkQ.png" /></figure><ul><li>由於上面我傳的 JSON 字串是將購物車數量放在 items_count 這個 key 的值，所以需要用 resp.items_count 才可以把數量撈出來，接下來就是 JS 的部分惹，用 innerText 把裡面的內容換成 resp.items_count</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/725/1*4PNge4LXWUHaVnwcbrCohQ.png" /></figure><p>只是記錄我做的過程，有錯的地方請指正QQ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ebfd1150929" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>