sublime 报错file text.html not in sublime project folder

sublime 报错file text.html not in sublime project folder


1.  遇到问题:如下代码第17行,获取本地json文件,如果直接在浏览器中打开引用该文件的.html文件,在chrme浏览器中并不能读取到json文件。

var vm=new Vue({
     el:"#app",
     data:{
         totalMoney:0,
         productList:[]
     },
     filters:{

     },
     mounted:function () {
         this.cartview();
     },
     methods:{
         
         cartview:function(){
                 var _this=this;
                 this.$http.get("data/cartData.json").then(function(res){
                 _this.productList=res.data.result.list;
                 _this.totalMoney=res.data.result.totalMoney;
             });
         }
     }
     
 
 });

浏览器错误提示:

2.  原因:chrome浏览器为了安全性考虑,默认对跨域访问禁止。

3.  解决方案:运用SublimeServer

(1)安装:

  sublime编辑器:perferences——packageControl——输入:Install Package——SublimeServer——进行安装。

(2)在Tools下可以查看到:SublimeServer——start SublimeServer

(3)到相应的页面——右键——view in sublimeServer

注意:  

  这时可能会出现问题:

    eg: File cart.html not in sublilme Project Folder!   

这是因为SublimeServer要求代码文件必须添加到Sublime Text的项目里:Porject——Add Folder to Project ——选择你的项目文件夹。

 

(4)再次执行步骤,便不会报错这错儿了~

此时在控制台看到可以正常加载json文件。

在Tools——SublimeServe——settings——查看SublimeServer的基本配置,可以设置修改服务器端口,文件扩展名等。

 

原创:http://www.mamicode.com/info-detail-1914788.html

### Sublime Text for Mac Installation and Usage Guide #### Installing Sublime Text on macOS To install Sublime Text on macOS, follow these instructions: 1. Visit the official website of Sublime Text[^1]. Download the .dmg file specifically designed for macOS. 2. Once downloaded, open the .dmg file by double-clicking it. This action mounts an image that contains the application installer. 3. Drag the Sublime Text icon into your Applications folder. After completing this process, Sublime Text will be installed on the macOS system and can be launched from Spotlight Search or the Applications folder. #### Configuring Sublime Text on macOS Configuring Sublime Text involves customizing settings to enhance productivity according to personal preferences or project requirements. - **Preferences**: Access configuration options through `Sublime Text` -> `Preferences`. Here one can modify user-specific (`Settings – User`) or global (`Settings – Default`) configurations. - **Key Bindings Customization**: Similar to setting up preferences, key bindings can also be customized under `Preferences` -> `Key Bindings`. For instance, adding a system-wide context menu option like “Edit with Sublime” requires additional steps outside direct Sublime Text setup but is achievable via third-party tools or scripts as mentioned elsewhere[^2]. #### Using Packages in Sublime Text Packages extend functionality within Sublime Text significantly. For example, installing plugins such as Package Control allows easy management over numerous extensions without manual intervention each time new software updates occur[^3]. If encountering issues where no packages appear available during installation attempts using Package Control, ensure correct placement of files inside the appropriate directory structure (e.g., placing directly under `~/Library/Application Support/Sublime Text/Packages/`). Restarting Sublime after making changes ensures all modifications take effect properly. Additionally, specific linters like SublimeLinter require external dependencies based upon which languages they support; e.g., Node.js must be present when working with JavaScript projects[^4]. ```bash brew cask install sublime-text ``` This command installs Sublime Text conveniently if Homebrew Cask is already set up on the machine. --related questions-- 1. How do I integrate Git commands seamlessly into Sublime Text workflows? 2. What are alternative methods besides dragging icons for launching applications post-installation on macOS systems? 3. Can you provide examples demonstrating advanced customization techniques through JSON-based preference editing in Sublime Text? 4. Which package repositories offer reliable sources beyond default ones provided initially by Sublime Text? 5. Is there any way to automate syntax checking across multiple programming environments efficiently while utilizing SublimeLinter?
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值