LoginSignup
0
1

More than 3 years have passed since last update.

G Suite(Google Apps Script)とVue.jsの連携

Last updated at Posted at 2019-12-04
vue.html
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.0"></script>

<script>  
  var app = new Vue({
    el: '#app',
    data: {
      email: '',
    },
    methods:{
      initEmail: function(sessionEmail){
        this.email = sessionEmail;
      },           
    },
    created: function(){
      google.script.run
        .withSuccessHandler(this.initEmail).getLoginID();
    },
  })
</script>
コード.js
function doGet() {
  var html = HtmlService.createTemplateFromFile("index").evaluate();
  return html;
}

function getLoginID() {
  var email = Session.getActiveUser().getEmail();
  Logger.log(email);
  return email;
}

index.html
<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
  <body>
  <div id="app">
    {{ email }}
  </div>
  </body>
  <?!= HtmlService.createHtmlOutputFromFile('vue').getContent(); ?>
</html>
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1