首先在asp.net项目中的web.config中加入:
然后在AppCode中的WebService.cs中加入:
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
[System.Web.script.Services.scriptService]
// 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消注释以下行。
// [System.Web.script.Services.scriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod(Description = "GetUserinfoList")]
public string GetUserinfoList()
{
DataSet ds = null;
string json = "";
string sql = "";
try
{
SqlParameter[] paras = new SqlParameter[1];
paras[0] = new SqlParameter("@today", SqlDbType.VarChar);
paras[0].Value = "";
sql = @"select * from Userinfo";
ds = SqlHelper.ExecuteDataset(getLocalConnection(), CommandType.Text, sql, paras);
if (ds == null || ds.Tables[0].Rows.Count == 0)
json = "";
else
json = JsonConvert.SerializeObject(ds.Tables[0], new DataTableConverter());
}
catch (Exception ex)
{
json = "";
}
return json;
}然后在vue的项目中引入js:
npm install jquery --save
然后在vue.config.js加入:
const webpack = require('webpack')
module.exports = {
devServer: {
overlay: {
warnings: false,
errors: false
}
},
lintOnSave: false,
publicPath: './',
chainWebpack: config => {
config.plugin('provide').use(webpack.ProvidePlugin, [{
$: 'jquery',
jquery: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery'
}])
}
}然后在页面中这么来使用:



