初学js的一些基础知识

最近在看js相关的东西,js主要用于前端开发。首先js编辑器:有sublime,nodepad,很多,我这里用的是sublime text3。

之前一直用sublime写pathon脚本,用这款编辑器写js还是刚开始尝试。现在通过对软件进行配置:

小笔记:

  安装插件管理器package controll,可以通过它在里面下载支持各种语言的插件。

  按 Ctrl + ~ 调出控制台 复制粘贴如下代码,并回车:

  如果你的是sublime text2 ,则复制sublime text2中的代码:

import urllib2,os,hashlib; h = '2deb499853c4371624f5a07e27c334aa' + 'bf8c4e67d14fb0525ba4f89698a6d7e1'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); os.makedirs( ipp ) if not os.path.exists(ipp) else None; urllib2.install_opener( urllib2.build_opener( urllib2.ProxyHandler()) ); by = urllib2.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); open( os.path.join( ipp, pf), 'wb' ).write(by) if dh == h else None; print('Error validating download (got %s instead of %s), please try manual install' % (dh, h) if dh != h else 'Please restart Sublime Text to finish installation')

  如果你的是sublime text3 ,则复制sublime text3中的代码:

import urllib.request,os,hashlib; h = '2deb499853c4371624f5a07e27c334aa' + 'bf8c4e67d14fb0525ba4f89698a6d7e1'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

This code creates the Installed Packages folder for you (if necessary), and then downloads the Package Control.sublime-package into it. The download will be done over HTTP instead of HTTPS due to Python standard library limitations, however the file will be validated using SHA-256.

  package controlor 已经安装好了,现在进入package controlor,

  在菜单栏“perference>package controlor",选择install packages.然后输入相应的插件,即可安装:

这些我已经安装过了。添加支持js的配置就可以了。

1、先下载支持js的软件:node.js,直接进入其官网去下载安装。

2、打开sublime text,在菜单栏tools——bulid system——new bulid system

在新打开的页面里输入:

{    
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": true,
"encoding": "utf-8",
"windows": {
    "cmd": ["node", "$file"]
    },
"linux": {
    "cmd": ["killall node; node", "$file"]
    }
}

细节:1、"selector": "source.js",写成缩写,可以自动选择编译系统

   2、如果运行结果出现乱码,"encoding": "utf-8",utf-8 改成 gbk

   3、上面的代码中,window内的内容在text2版本里:"cmd": ["taskkill /f /im node.exe >nul 2>nul & node", "$file"],在text3版本里:"cmd": ["node", "$file"]

3、完成之后文件名保存为:javascript.sublime-build,保存位置默认。然后重启sublime text3。

4、在菜单栏tools——bulid system,勾选上JavaScript,打开一个新文件输入:

console.log('y54rytr');
console.log('str');
console.log('7i76op9');
 保存,然后运行:Ctrl+b或者直接点bulid,如图所示:
暂时先看到这里。
posted @ 2016-04-12 16:53  Mytesting  Views(192)  Comments(0Edit  收藏  举报